jquery noConflict jquery.mobile

memic84

我正在使用两个版本的jQuery,我想开始使用jQuery mobile。参见下面的代码:

<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版本。

凯文·罗斯

我知道这个问题很旧,但是仍然存在。

这是我的解决方案的摘要:

<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

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章