我正在使用两个版本的jQuery,我想开始使用jQuery手机。见下文代码:
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery-2.1.0.min.js"></script>
<script type="text/javascript">var jQuery_2_1_0 = $.noConflict(true);</script>
<script type="text/javascript" src="jquery.mobile-1.4.2.min.js"></script>
现在的问题是,jquery.mobile识别了1.4.2版本的jquery。
如何告诉jquery.mobile使用2.1.0版本?
!!noConflict不能用于1.4.2版本,因为遗留代码和一个jquery版本暂时不是一个选项。
发布于 2015-09-09 17:36:05
我知道这个问题很老,但它仍然是开放的。
下面是我的解决方案的一个片段:
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/1.2.6/jquery.min.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js'></script>
<script>
$(function () {
// jQuery Mobile has loaded with the newer version of jQuery, so
// now we set $ back to the original version of jQuery & set new version to jq2
var jq2 = jQuery.noConflict();
});
</script>
参见CodePen:http://codepen.io/rothkj1022/pen/gapNeP上的其余部分
https://stackoverflow.com/questions/22204191
复制相似问题