解决方法
这被称为关闭以避免与使用$的其他库冲突.这样,您可以确保在该函数中使用$,将jQuery作为参数传递.
(function ($) { $(function () { ....... }); })(jQuery); //<----passing jquery to avoid any conflict with other libraries.
从文档:
it’s a best practice to pass jQuery to an IIFE (Immediately Invoked Function Expression) that maps it to the dollar sign so it can’t be overwritten by another library in the scope of its execution.
This is generally used to author plugins. Read out more here