【问题标题】:pug :link is a self closing element: <link/> but contains nested contentpug :link 是一个自闭合元素: <link/> 但包含嵌套内容
【发布时间】:2018-10-14 17:36:17
【问题描述】:

错误显示在下面一行:

    link(rel='stylesheet',href='https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css')

以下是标记:

html
  head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css',type='text/css')
    link(rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css",type='text/css')
  body
    .add-entry
      h3#title Add an entry
        form(id='add', method='post', action='/entry/add')
            .form-group
                label(for='comment') 
                h6  Description:
                input#comment.form-control(rows='5' type='text' size='30' name='description')
            .form-group
                label(for='sev') 
                h6 Severity
                select#sev.form-control(name='severity')
                    option Low
                    option Average
                    option Critical
                br
                br    
                button.btn.btn-primary(type='submit') Submit

有人可以帮忙吗?更新了标记。错误显示在第 4 行

【问题讨论】:

  • 仅供参考,如果您缩进了定义 link 元素的行下方的行,则会发生此错误。
  • 是的,这是有意的问题..谢谢
  • 请将答案标记为“已接受”,因为它会将问题标记为已正确回答。这让其他用户在搜索时一眼就知道它有解决方案。
  • 对我来说,它是链接和左括号之间的空格。

标签: pug


【解决方案1】:

当您缩进链接元素下方的行时会发生此错误,如下所示:

head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css',type='text/css')
      link(rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css",type='text/css')

这会尝试在另一个链接元素内创建一个链接元素,但该元素(如错误所示)无效。

以后,请确保您的所有链接元素都在同一级别对齐:

head
    title= title
    link(rel='stylesheet', href='/stylesheets/style.css',type='text/css')
    link(rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css",type='text/css')

【讨论】:

    猜你喜欢
    • 2016-11-12
    • 1970-01-01
    • 1970-01-01
    • 2021-01-02
    • 1970-01-01
    • 2010-11-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-06
    相关资源
    最近更新 更多