我在模板继承方面存在问题(更确切地说,- block css )。 我有嵌套的模板:template.pug-> index.pug-> contactContainer.pug
每个文件都有阻止CSS 。并且template.pug通过index.pug和contactContainer.pug获取所有块css(是正确的),但是在html中复制contactContainer.css:
<div id="leftColumn">
<link rel="stylesheet" href="/stylesheets/layouts/main/contactContainer.css">
<div id="contactContainer">
<div id="concatSubcontainer"></div>
</div>
</div>
我认为我使用“ 包含”而不是“ 扩展”来解决问题,但是我不确定,因为我对Pug的使用经验很少。
示例文件:
template.pug (主模板文件)
doctype html
html
head
include ./head
block css
block js
body
div(id="page")
include ./header
block body
include ./footer
index.pug (正文文件)
extends layouts/main/template
block append css
link(rel="stylesheet" type="text/css" href="/stylesheets/index.css")
block body
div(id="mainContainer")
div(id="leftColumn")
include ./layouts/main/contactContainer
div(id="rightColumn")
include ./layouts/main/selfContainer
contactContainer.pug ( leftColumn 的模板)
block append css
link(rel='stylesheet', href='/stylesheets/layouts/main/contactContainer.css')
div(id="contactContainer")
div(id="concatSubcontainer")