正确地在快速js应用程序中包含jquery mobile

Fer*_*deh 3 jquery node.js jquery-mobile express

我在快递应用程序中包含jquery js文件时遇到问题.我将jquery.js文件添加到/ public/javascripts文件夹,我将layout.jade文件更改为如下:

!!!5
html
  head
    title= title
    meta(name='viewport', content='width=device-width,initial-scale=1')
    link(rel='stylesheet', href='/stylesheets/style.css')
    link(rel='stylesheet', href='/stylesheets/jquery.mobile-1.0.1.min.css')
    script(type='text/javascript', src='/javascripts/jquery.mobile-1.0.1.min.js')
    script(type='text/javascript', src='/javascripts/jquery-1.7.2.min.js')
  body!= body
Run Code Online (Sandbox Code Playgroud)

我还包括app.use(express.static(__ dirname +'/ public')); 在我的app.js.I我改变了我的index.jade,包括一些jquery移动标签:

div(data-role='page')
div(data-role='header')
    h1= title

div(data-role='content')    
    ul(data-role='listview',data-inset='true',data-filter='true')
            li: a(href='#') Acura
Run Code Online (Sandbox Code Playgroud)

问题是我无法正确渲染网页.我看不到任何jquery相关的样式.任何人都知道如何解决这个问题?

谢谢,

Jas*_*per 7

您需要在jQuery Mobile文件之前包含jQuery Core文件,因为后者扩展了前者; 因此,如果在包含Mobile时Core不存在,则会出现错误.

您可以在此处引用正确的顺序以包含jQuery和jQuery Mobile文件:http://www.jquerymobile.com/download/

您还使用了错误的jQuery Core版本(请查看上面的链接以获取正确的版本):

  • jQuery Mobile 1.0.1支持jQuery Core 1.6.4.
  • jQuery Mobile 1.1.0 RC-1支持jQuery Core 1.7.1.jQuery Mobile目前不支持jQuery Core 1.7.2(如本博文中所述).

最后,我将在jQuery Mobile之后包含您的自定义CSS样式表,以便更轻松地覆盖jQuery Mobile CSS.