express - 无法扩展哈巴狗的布局

标签 express pug

在我的索引文件中,我使用以下标记扩展布局:

extends layout
html
  script(src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js')
  link(rel='stylesheet', href='/stylesheets/style.css')    
  link(rel='stylesheet',href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css')
  script(src='//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js')
block content
  h1= title

body

  nav
    .navbar.navbar-inverse
    .container-fluid
    .navbar-header
  a
    .navbar-brand(href='#') WebSiteName
  ul.nav.navbar-nav
    li.active
      a(href='#') Home
    li
      a(href='#') Issues
    li
      a(href='#') Page 2
    li
      a(href='#') Page 3

我收到以下错误:只有命名 block 和混合可以出现在扩展模板的顶层。

用谷歌搜索并尝试了一些没有帮助的基本修复

布局.pug:

doctype html
html
  head
    title= title
    link(rel='stylesheet', href='stylesheets/style.css')
  block content  
  body
   nav
    .navbar
    .container-fluid
    .navbar-header
   a
    .navbar-brand(href='#') WebSiteName
    ul.nav.navbar-nav
      li.active
        a(href='#') Home
      li
        a(href='#') Page 1
      li
        a(href='#') Page 2
      li
        a(href='#') Page 3

最佳答案

可以分享你的扩展布局代码吗?也可以尝试给 body 和它的子元素一个标签。

extends layout


block content
    h1= title

    body
        script(src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js')
        link(rel='stylesheet', href='/stylesheets/style.css')    
        link(rel='stylesheet',href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css')
        script(src='//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js') 
        nav
            .navbar.navbar-inverse
            .container-fluid
            .navbar-header
        a
            .navbar-brand(href='#') WebSiteName
        ul.nav.navbar-nav
            li.active
              a(href='#') Home
            li
              a(href='#') Issues
            li
              a(href='#') Page 2
            li
              a(href='#') Page 3

关于express - 无法扩展哈巴狗的布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52706618/

相关文章:

python - 使用 python API POST(请求库)时 Node Express 正文为空

javascript - 电子邮件验证 nodemailer 适用于本地主机但不适用于服务器

javascript - 在 Pug 中打印数组元素

express - 如何通过grunt-usemin更新Jade文件CSS,JS引用

node.js - 使用jade模板引擎插入Meta

javascript - 如何重新路由多个 Express.js 路径并返回单个结果?

node.js - 服务客户端 Jade 模板

node.js - 什么是 Express.js?

javascript - 使用括号表示法添加到关联数组时,ng-repeat 不会更新

node.js - 如何在 Gulp-Jade 中设置默认文档类型