首页 > 解决方案 > jQuery升级——jquery.mobile添加类

问题描述

我们目前正在将我们的 jQuery 版本从 1.10 升级到 3.3.1

结果,我们还必须安装 jquery.mobile v1.5.0(因为这是唯一与 v3 兼容的)

jquery.mobile 正在向我的页面添加类以及其他 div 元素(data-role="page"例如)

有没有办法阻止 jquery.mobile 这样做/禁用它。我的页面布局受到这些新类的影响

标签: jqueryjquery-mobile

解决方案


禁用 jQM$.mobile.autoInitializePagemobileinit.

<head>
  <!-- jQuery.js here -->
  <script>
    $(document).on("mobileinit", function () {
      $.mobile.autoInitializePage = false;
    });
  </script>
  <!-- jQuery Mobile.js here -->
</head>

要手动初始化框架,请使用$.mobile.initializePage();.


推荐阅读