你需要改变这个:
$.fn.modal = $.extend(function(option) {
// your code ...
}, $.fn.modal);
为了这:
$.extend($.fn.modal, function(option) {
// your code ...
});
TL;DR
$.extend(a, b)
复制内容b on a (修改其内容),如果有重复,则属性b遗迹。此外,它返回的值a.
所以,如果你有这个:
hello = { unique_on_hello: 'hola', message: 'hello message' }
world = { unique_on_world: 'mundo', message: 'WORLD MESSAGE' }
response = $.extend(hello, world)
每一项的值将是:
hello // {unique_on_hello: "hola", message: "WORLD MESSAGE", unique_on_world: "mundo"}
world // {unique_on_world: "mundo", message: "WORLD MESSAGE"}
response // {unique_on_hello: "hola", message: "WORLD MESSAGE", unique_on_world: "mundo"}
所以,如果你这样做f2 = $.extend(f1,f2);
是相同的:
$.extend(f1, f2) // Copy properties of f2 to f1
f2 = f1
Source: https://api.jquery.com/jquery.extend/ https://api.jquery.com/jquery.extend/