更新时间:2023-02-14 18:15:01
这个问题的一个常见解决方案是使用 jQuery 的内置 $.noConflict(true)
但我建议你在您的底部 标记代码中使用以下内容以防止 jQuery 的双重加载:
A common solution to this problem would be to use jQuery's built-in $.noConflict(true)
but I would suggest you to use the following in your bottom <script>
tag code to prevent the double loading of jQuery altogether:
requirejs.config({
paths: {
jquery: '../vendors/jquery/dist/jquery.min.js'
}
});
if (typeof jQuery === 'function') {
//jQuery already loaded, just use that
define('jquery', function() { return jQuery; });
}
require(["jquery"], function($) {
//This $ should be from the first jquery tag, and no
//double load.
});
来源:https://github.com/requirejs/requirejs/issues/535
去掉一个包含是行不通的,因为:
Getting rid of one include won't work because:
标签)<script src="jQuery.min.js">
标签(底部标签)加载立>
<script>
tag)<script src="jQuery.min.js">
tag (bottom tag)