我创建了类似这样的 JQuery 小部件
<script type="text/javascript">
(function ($) {
$.widget("cb.bacon", {
_create: function() {
var self = this,
o = self.options,
el = self.element;
// Some code
},
_bacon: function() {
var self = this,
o = self.options,
el = self.element;
// Some code
},
_smokey: function() {
var self = this,
o = self.options,
el = self.element;
// Some code
}
});
})(jQuery);
</script>
我总是不得不在我创建的每个函数中声明self
, 。options
element
是否有一些基本的理解我错过了,或者我真的必须一直这样做?