慕粉1467970169
2016-12-11 20:07
$.fn.PageSwitch = function(options) {
return this.each(function() {
var $me = $(this);
var instance = $me.data("PageSwitch")
if (!instance) {
instance = new PageSwitch($me, options);
$me.data("PageSwitch", instance)
}
$('div').PageSwitch('init') 这是怎样调用init方法的??这样写不是将init作为参数传递进去了?
if ($.type(options) == "string") {
return instance[options]();
}
})
}
if ($.type(options) == "string") {
return instance[options]();
}
这里他在演示如果需要调用init方法需要怎么做。
他这里有判断如果传进去是个字符串的话,就调用实例上面的对应的方法。
instance[options]();
这里instance是instance = new PageSwitch($me, options);
实例可以调用构造函数prototype上的方法。
全屏切换效果
85457 学习 · 166 问题
相似问题