我在 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
我还包含了 app.use(express.static(__dirname + '/public'));在我的 app.js 中。我按如下方式更改了 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
问题是我无法正确呈现网页。我看不到任何与 jquery 相关的样式。有人知道我该如何解决这个问题吗?
谢谢,
最佳答案
您需要在 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(如 this blog post 中所述)。
最后,我会在 jQuery Mobile 之后包含您的自定义 CSS 样式表,以便更轻松地覆盖 jQuery Mobile CSS。
关于jquery - 在 express js 应用程序中正确包含 jquery mobile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10078535/