文档说你可以像这样使用$.noConflict():
jQuery.noConflict(); (function($) { $(function() { // more code using $as alias to jQuery }); })(jQuery); // other code using $as an alias to the other library
它还声明调用它返回jQuery对象的实例,所以我可以这样做:
jQuery.noConflict()(function(){ // code using jQuery }); // other code using $as an alias to the other library
但是,这种组合有效吗?
(function($) { $(function() { // more code using $as alias to jQuery }); })(jQuery.noConflict()); // other code using $as an alias to the other library
如果是这样,有没有理由不这样做?而且(如果它工作),为什么不总是使用这个方法来保证我们的闭包内部,$== jQuery?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。