【问题标题】:Upgrade jQuery 1.7.3 to 1.8.0+ Syntax error [data-role]=page] (in combination with jQuery Mobile)将 jQuery 1.7.3 升级到 1.8.0+ 语法错误 [data-role]=page](与 jQuery Mobile 结合使用)
【发布时间】:2014-07-08 10:06:14
【问题描述】:

所以我正在尝试将我的移动网站的 jQuery 从 1.7.3 升级到 1.8 以上,但是当我这样做时,我得到了这个控制台错误:

[Error] Error: Syntax error, unrecognized expression: [data-role]=page              error (jquery-1.8.0.js, line 4512)
tokenize                                                                                  (jquery-1.8.0.js, line 4785)
compile                                                                                   (jquery-1.8.0.js, line 4883)
select                                                                                    (jquery-1.8.0.js, line 4973)
select                                                                                    (jquery-1.8.0.js, line 5083)
Sizzle                                                                                    (jquery-1.8.0.js, line 3912)
find                                                                                      (jquery.mobile-1.3.2.js, line 348)
matchesSelector                                                                           (jquery.mobile-1.3.2.js, line 358)
filter                                                                                    (jquery-1.8.0.js, line 5371)
is                                                                                        (jquery-1.8.0.js, line 5218)
dispatch                                                                                  (jquery-1.8.0.js, line 3027)
eventHandle                                                                               (jquery-1.8.0.js, line 2677)
trigger                                                                                   (jquery-1.8.0.js, line 2941)
(anonymous function)                                                                      (jquery-1.8.0.js, line 3607)
each                                                                                      (jquery-1.8.0.js, line 611)
each                                                                                      (jquery-1.8.0.js, line 241)
trigger                                                                                   (jquery-1.8.0.js, line 3606)
_trigger                                                                                  (jquery.mobile-1.3.2.js, line 835)
(anonymous function)                                                                      (jquery.mobile-1.3.2.js, line 4065)
fire                                                                                      (jquery-1.8.0.js, line 973)
add                                                                                       (jquery-1.8.0.js, line 1016)
transitionPages                                                                           (jquery.mobile-1.3.2.js, line 4058)
changePage                                                                                (jquery.mobile-1.3.2.js, line 4708)
initializePage                                                                            (jquery.mobile-1.3.2.js, line 11158)
(anonymous function)                                                                      (jquery.mobile-1.3.2.js, line 11192)
fire                                                                                      (jquery-1.8.0.js, line 973)
fireWith                                                                                  (jquery-1.8.0.js, line 1080)
ready                                                                                     (jquery-1.8.0.js, line 406)
DOMContentLoaded                                                                          (jquery-1.8.0.js, line 83)

这个错误的结果是我什么都做不了。我无法切换页面,iScroll 也不行。

我不知道错误可能出现在我的代码中,因为我没有看到对 jQuery 库以外的任何其他内容的错误引用,所以我真的不知道在此处放置什么代码。这不是我自己编写的代码。干杯:)

【问题讨论】:

    标签: jquery-mobile jquery-1.7 jquery-1.8


    【解决方案1】:

    似乎选择器有拼写错误,应该是[data-role=page](请在源码中搜索)。

    当您使用它时,请务必升级到 JQM 1.3.2 支持的最新 jQuery:

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
    

    【讨论】:

    • 谢谢,这有帮助(这很愚蠢),我没有编写这部分代码,所以我很感激:D。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-28
    • 1970-01-01
    • 1970-01-01
    • 2012-12-22
    • 2017-02-22
    • 2012-05-15
    相关资源
    最近更新 更多