【问题标题】:input is self closing and should not have content Jade-Lang issues输入是自动关闭的,不应该有内容 Jade-Lang 问题
【发布时间】:2014-12-11 03:54:35
【问题描述】:

我目前正在研究一些 Node.js ExpressJS 和 MongoDB,并且遇到了 Jade 的障碍。当我转到我的新用户页面时,我不断收到input is self closing and should not have content 错误。我已经检查了该站点上的所有内容,浏览了jade-lang 文档并提出了不足,真的可以对这个 Jade 恶作剧使用一些指导。谢谢大家!!

这是我的代码:

extends layout


block content
  h1= title
  form#formAddUser(name="adduser",method="post",action="/adduser")
    input#inputUserName(type="text", placeholder="username", name="username")
      input#inputUserEmail(type="text", placeholder="useremail", name="useremail")
        button#btnSubmit(type="submit", value="submit")

这是我的错误信息:

/home/evan/dev/nodetest1/views/newuser.jade:7 5| //- h1= title 6| form#formAddUser(name="adduser",method="post",action="/adduser") > 7| input#inputUserName(type="text", placeholder="username", name="username") 8| input#inputUserEmail(type="text", placeholder="useremail", name="useremail") 9| button#btnSubmit(type="submit", value="submit") 10| input is self closing and should not have content.

【问题讨论】:

    标签: node.js mongodb express pug


    【解决方案1】:

    该错误准确地说明了问题所在,但除非您知道如何翻译它,否则这并不意味着它很容易理解:D

    input#inputUserName(type="text", placeholder="username", name="username")
      input#inputUserEmail(type="text", placeholder="useremail", name="useremail")
        button#btnSubmit(type="submit", value="submit")
    

    将尝试将#inputUserEmail 放入#inputUserName#btnSubmit 放入#inputUserEmail,因为缩进。应该只是

    input#inputUserName(type="text", placeholder="username", name="username")
    input#inputUserEmail(type="text", placeholder="useremail", name="useremail")
    button#btnSubmit(type="submit", value="submit")
    

    这是因为在 HTML 中,<input> 元素没有子元素,因此不允许嵌套。

    【讨论】:

    • 非常感谢。甚至不认为 Jade 是缩进敏感的,但这完全有道理。再次感谢您的帮助。
    猜你喜欢
    • 2014-01-11
    • 1970-01-01
    • 1970-01-01
    • 2016-11-12
    • 2017-11-04
    • 1970-01-01
    • 2023-03-22
    • 2013-04-20
    • 1970-01-01
    相关资源
    最近更新 更多