如何阻止 JQM 设置页面样式? [英] How to stop JQM from styling a page?
问题描述
我有一个 JQM 应用程序,其中包含一个我不想设置样式的特定页面.
I have a JQM app with one specific page that I do not want styled.
到目前为止我发现的只是 data-role='none'
- 但我不想将它应用到页面上的每个元素......有没有办法如果仅针对这一页关闭?
All I have found so far is data-role='none'
- but I don't want to have to apply that to every element on the page... Is there a way to turn if off just for this one page?
推荐答案
您可以将 data-enhance="false"
与 $.mobile.ignoreContentEnabled=true
结合使用> 停止 jQuery Mobile 对伪页面的自动增强:
You can use data-enhance="false"
in conjunction with $.mobile.ignoreContentEnabled=true
to stop the auto-enhancement that jQuery Mobile does to a pseudo-page:
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
$(document).on('mobileinit', function () {
$.mobile.ignoreContentEnabled = true;
});
</script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
<div data-enhance="false" data-role="page">
...
</div>
您必须更改 ignoreContentEnabled
标志的原因是因为搜索 data-attribute
的父元素会占用大量 CPU,因此默认情况下这是关闭的.
The reason you have to change the ignoreContentEnabled
flag is because it's CPU intensive to search parent elements for the data-attribute
, so this is turned-off by default.
这是一个演示:http://jsfiddle.net/ZtJyL/1/
这篇关于如何阻止 JQM 设置页面样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!