Jquery插件开发的小注意

Jquery.fn.extend({ method1:function(){...},method2:function(){...}});

$.fn.extend({ method1:function(){...},method2:function(){...}});

$.fn.method1=function(){...}

$.fn.method2=function(){...}

以上皆表示同一个意思

Jquery.extend({ method1:function(){...},method2:function(){...}});

$.extend({ method1:function(){...},method2:function(){...}});

$.method1=function(){...}

$.method2=function(){...}

以上皆表示同一个意思

有个地方也值得注意就是$.extend另外的用法,例如:

var opts = $.extend({},defaultArg, arg);

它表示的意思是在defaultArg上进行arg的扩展,把整合的数组放到一个空数组中返回.

通俗的讲就是取defaultArg和arg的并集,但arg的优先级要高与defaultArg.

原文地址:https://www.cnblogs.com/easyleo/p/1437323.html