玉字不被识别

Jade - script not being recognized

本文关键字:识别      更新时间:2023-09-26

我有一个非常简单的jade文档,我想导入标准的jQuery脚本:

extends layout
block content
    h1 #{title}
    ul#messages
    form#formAddUser(name="adduser",method="post",action="")
        input#m(type="text", name="message")
        button#btnSubmit(type="submit") submit
    script(src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js")

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

问题是,脚本甚至不被识别!我宁愿得到404响应,但即便如此,什么也没有发生。我做错了什么?

Thanks very much

p。S:我正在使用express.js

控制器代码:

router.get("/chat",function(req,res){
    res.render("chat",{title:"Chat"});
});

更新:我在布局中添加了一块

doctype html
html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
    script(type="text/javascript")
      alert("hello!")
  body
    block content

这个简单的警报,它也不起作用!

在jade中添加一个点用于文本解析。Ie .

doctype html
html
    head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css')
    script(type="text/javascript").
        alert("hello!")
        console.log('Notice the dot after the script tag.');
body
    block content

如果你添加一个点,任何块(因此缩进)将不会被解析。这样的:

ul
    li This is inlined text.
    li.
       But this one is on its' own line, without the But being turned into a tag.
    li
       div this is a div inside a li
    li.
       div this is not a div, simple text inside a li.
p For added bonus, you can also use a colon and the next thing is also a tag.
p like, opposite of the dot.
p: a(href="#") Clickme!
p a(href="#") I'm not clickable :(

翡翠很酷,不是吗?

EDIT:哎呀,刚刚注意到警报('hello')只是您原始问题的附录。让我更新一下答案。

编辑2:实际上,你可以显示你渲染的HTML(第一个例子),所以我可以看到什么是实际渲染和你期望在那里?