大佬教程收集整理的这篇文章主要介绍了javascript – 模块模式 – 为什么JQuery作为参数传入?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Namespace.AppName = (function ($) { // Code Here })(jQuery);
如果我没有传入JQuery,我仍然可以通过在模块内部进行$()调用来使用Jquery库.那么为什么有些人这样做呢?
例如,如果您在< head>中使用此代码
<!--load jQuery--> <script src="jquery.js"></script> <script> //"$" is jQuery //"jQuery" is jQuery </script> <!--load another library--> <script src="anotherlibrary.js"></script> <script> //"$" is the other library //"jQuery" is jQuery //out here,jQuery code that uses "$" breaks (function($){ //"$" is jQuery //"jQuery" is jQuery (from the outside scopE) //in here,jquery code that uses "$" is safe }(jQuery)); </script>
以上是大佬教程为你收集整理的javascript – 模块模式 – 为什么JQuery作为参数传入?全部内容,希望文章能够帮你解决javascript – 模块模式 – 为什么JQuery作为参数传入?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。