不兼容的jQuery Mobile和UI [英] Incompatible jquery mobile and ui

查看:276
本文介绍了不兼容的jQuery Mobile和UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管我有很多人在提到类似的兼容性问题,但是他们的问题有50%在StackOverflow上得到了解决.我希望我的问题能达到51-49:)

Although I have a ton of people referencing to similar compatibility issues, 50% their problems are solved on StackOverflow. I am hoping my question will make it 51-49 :)

考虑以下代码:

<html>
<head>
  <title>Hello, world!</title>
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
  <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>
</head>
<body>
  Hello
</body>
</html>

如果将其加载到网页上,则浏览器中间将出现一个灰色圆圈,并且不会显示单词"Hello".在网络控制台上,您将看到以下内容:未捕获的TypeError:对象0没有方法'match'(Chrome)或 TypeError:c.match不是函数 (Firefox)或 SCRIPT438:对象不支持属性或方法匹配" (IE).

If you load this on a web page, you will get a grey circle in the middle of the browser and the word "Hello" is not displayed. On the web console, you'll see the following: Uncaught TypeError: Object 0 has no method 'match' (Chrome) or TypeError: c.match is not a function (Firefox) or SCRIPT438: Object doesn't support property or method 'match' (IE).

同时在页面上同时使用jquery-ui和jquery-mobile是一个坏主意,还是我做错了什么?

Is it a bad idea to want to use both jquery-ui and jquery-mobile on a page together, or am I doing something wrong?

推荐答案

仅相关的是命令,在jUI之后加载jQM,css文件也是如此:

Only thing relevant is an order, load jQM after jUI, same thing goes for css files:

<!DOCTYPE html>
<html>
<head>
  <title>jQM Complex Demo</title>
  <meta name="viewport" content="width=device-width"/>
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />    
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
  <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
  <script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>    
  <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
    <div data-role="page" id="index">    
      Hello
    </div>
</body>
</html>

还需要:

<!DOCTYPE html>

这将阻止ajax加载程序的舞会显示:

And this will prevent ajax loader prom showing:

<div data-role="page" id="index">    
    Hello
</div>

这篇关于不兼容的jQuery Mobile和UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆