如果我有一个使用正常标准的 jQuery 插件:
(function( $ ){
var methods = {
init : function( options ) {
var defaults = {
}
var options = $.extend(defaults, options);
return this.each(function(){
var returnValue = myUniversalFunction();
});
},
test : function( options ) {
var defaults = {
}
var options = $.extend(defaults, options);
return this.each(function(){
var returnValue = myUniversalFunction();
});
}
};
$.fn.jPlugin = function( method ) {
if ( methods[method] ) {
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.tooltip' );
}
};
})( jQuery );
我应该在哪里放置一个可以在 init 和 test 方法中访问但不能在插件本身之外使用的函数?