使用requirejs-无法扩展jquery
我试图在requiredefine函数中扩展jquery。但我无法扩展。任何人都可以帮我分类: 这是我的密码:使用requirejs-无法扩展jquery,jquery,jquery-plugins,Jquery,Jquery Plugins,我试图在requiredefine函数中扩展jquery。但我无法扩展。任何人都可以帮我分类: 这是我的密码: define(['jquery'],function($){ // $ available here. $.fn.extend({ valid : function () { console.log('validate now'); } }); console.log($.valid); //c
define(['jquery'],function($){
// $ available here.
$.fn.extend({
valid : function () {
console.log('validate now');
}
});
console.log($.valid); //console as undefined-why?
});
正如NULL所说,我是这样使用的:
$.extend({valid: function() {}})
它很好用。谢谢大家 您是否尝试过
$.valid=function(){}
或$.extend({valid:function(){}})
。执行$(选择器)时,可以访问存储在$上的所有方法。fn
让我试试您的方法。