1
我想重載一個插件的方法。如何在JS中重新定義對象方法?
這是我使用的插件。 http://www.owlgraphic.com/owlcarousel/owl-carousel/owl.carousel.js
該庫包含以下方法:
updateControls : function() {
var base = this;
base.updatePagination();
base.checkNavigation();
if (base.owlControls) {
if (base.options.items >= base.itemsAmount) {
base.owlControls.hide();
} else {
base.owlControls.show();
}
}
},
這是我的方法重載腳本:
jQuery(document).ready(function($){
$.fn.owlCarousel = $.extend($.fn.owlCarousel, {
updateControls:function()
{
console.log("!!");
var base = this;
base.updatePagination();
base.checkNavigation();
if (base.owlControls) {
base.owlControls.show();
base.owlControls.show();
}
}
});
})
console.log("!!");
不會出現被稱爲 - 我究竟做錯了什麼?