importing jQuery with jade(with node.js + express)

importing jQuery with jade(with node.js + express)

我有关于翡翠的问题。我像 follow 一样导入,但它似乎被忽略了。(当我用 Chrome 检查源代码时,找不到那些资源:<)

扩展布局

head block append
  link(rel='stylesheet', href='/stylesheets/chat.css')
  script(src="/socket.io/socket.io.js")
  script(src="/javascripts/jquery-2.1.4.min.js")
  script(src="/javascripts/chat.js")

如何导入这些脚本?

谢谢!

//=============== 这是我在 Chrome 浏览器的 'page source' 功能时得到的结果。

<!DOCTYPE html>
<html>
<head>
    <title>Chat Sample</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
</head>
<body>
    <h1>Chat</h1>
    <label for="userName">User name: (Hit Enter)</label>
    <input id="userName" type="text" size="30">
    <span id="feedBack"></span>
    <p> </p>
    <div id="msgWindow" class="shadow">
    </div>
    <p> </p>
    <div>
        <br>
        <table>
            <tr>
                <td>
                    <select id="users" style="width: 100px"></select>
                </td>
                <td>
                    <input id="msg" type="text" style="width: 600px" disabled="true">
                </td>
            </tr>
        </table>
    </div>
</body>
</html>

但是,css 文件也没有应用到页面。当我像 http://localhost:3000/javascripts/jquery-2.1.4.min.js.

这样的 url 接近时,我可以获得文件的完整内容

我已经更改了jquery版本//

//===========编辑

错误如下。我不明白为什么 head 是意外的//

Warning: Unexpected block "head"  on line 3 of /Users/juneyoungoh/Documents/Nodejs/ChatSample/views/chat.jade. This block is never used. This warning will be an error in v2.0.0

仅供参考,这是 layout.jade

doctype html
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
  body
    block content

从未附加块,但 jade-lang.com 提到了以下语法:

extends layout

block append head
  link(rel='stylesheet', href='/stylesheets/chat.css')
  script(src="/socket.io/socket.io.js")
  script(src="/javascripts/jquery/jquery-1.7.2.min.js")
  script(src="/javascripts/chat.js")

http://jade-lang.com/reference/inheritance/

我从 Jannik 的评论中得到了提示。可能是版本问题。 总之,我编辑了 layout.jade.

来自

doctype html
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
  body
    block content

doctype html
html
  block head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
  body
    block content

我添加了block关键字。

仅供参考,我正在使用

  • npm ver.2.12.1
  • 节点版本 0.10.23
  • 快递ver.3.4.7

和package.json喜欢

{
  "name": "application-name",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "3.4.7",
    "jade": "*"
  }
}

感谢您的帮助! :D