当您首先在锚点加载页面然后导航回包含导航栏的主页(在 html 文件中找到的第一页)时,会发生此错误。
锚页面(刷新锚页面上的浏览器):
manager.html?accountId=5#page-device-settings
使用链接导航回主页。
a href="#page-dashboard"
主页
manager.html?accountId=5
包含取自 ( https://api.jquerymobile.com/tabs/ )的导航栏示例
<div data-role="tabs">
<div data-role="navbar">
<ul>
<li><a href="#fragment-1" class="ui-btn-active">One</a></li>
<li><a href="#fragment-2">Two</a></li>
<li><a href="#fragment-3">Three</a></li>
</ul>
</div>
<div id="fragment-1">
<p>This is the content of the tab 'One', with the id fragment-1.</p>
</div>
<div id="fragment-2">
<p>This is the content of the tab 'Two', with the id fragment-2.</p>
</div>
<div id="fragment-3">
<p>This is the content of the tab 'Three', with the id fragment-3.</p>
</div>
</div>
在 chrome 调试器中,您可以看到抛出此错误。
Uncaught Error: Syntax error, unrecognized expression: :nth-child
at Function.db.error (jquery-2.1.0.min.js?_=1516664627221:2)
at Object.CHILD (jquery-2.1.0.min.js?_=1516664627221:2)
at ob (jquery-2.1.0.min.js?_=1516664627221:2)
at xb (jquery-2.1.0.min.js?_=1516664627221:2)
at Function.db (jquery-2.1.0.min.js?_=1516664627221:2)
at Function.a.find (jquery.mobile-1.4.5.js:1367)
at Function.a.find.matches (jquery.mobile-1.4.5.js:643)
at Function.o.filter (jquery-2.1.0.min.js?_=1516664627221:2)
at x (jquery-2.1.0.min.js?_=1516664627221:2)
at o.fn.init.filter (jquery-2.1.0.min.js?_=1516664627221:2)
版本:
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
任何人都知道为什么会发生这种情况以及如何解决它?
我不确定这是否重要,但有趣的是,在 Chrome 中使用 Spy 插件时,我可以看到以下请求触发了两次。在锚定页面的初始加载期间一次,然后在我导航回主页时再次。这仅在导航主页 -> 锚定页面 -> 主页时发生一次。
Method: Get Type: html URL: manager.html