玉意外块错误
Jade Unexpected block Error
注意:类似于this问题,但不一样。
我有一个 expressjs 节点网站 (WIP),但我不断收到以下错误:
Warning: Unexpected block "head" on line 3 of \src\dynamic\views\index.jade. This block is never used. This warning will be an error in v2.0.0
Warning: Unexpected block "body" on line 5 of \src\dynamic\views\index.jade. This block is never used. This warning will be an error in v2.0.0
我的src\dynamic\views\index.jade
:
extends _includes/head/head
block head
title Skool - On Our Way!
block body
extends _includes/navbars/topNav
_includes/navbars/topNav.jade
文件只是一个基本的 jade 文件,描述了一个简单的 bootstrap 导航栏,所以我将省略它。
_includes/head/head
:
doctype html
html
head
link(rel="styleSheet" href="css/main.css")
script(src="js/app.js")
block head
body
block body
现在当我访问localhost:3000
时,迎接我的是我编译好的jade文件,除了<head>
元素是空的,所以没有css链接!检查控制台日志我看到前面提到的 error/warning.
我做错了什么?
非常感谢 @Molda 为我指明了正确的方向。 (S)他说:
I think that you should only use extends once in your view. Use include for topNav.
所以我一替换那个扩展它就起作用了,我的 <head>
元素不再是空的。
现在我找不到任何记录 "you can only use extends
once" 规则的内容,但据我所知,只使用了最后一个扩展。
注意:类似于this问题,但不一样。
我有一个 expressjs 节点网站 (WIP),但我不断收到以下错误:
Warning: Unexpected block "head" on line 3 of \src\dynamic\views\index.jade. This block is never used. This warning will be an error in v2.0.0 Warning: Unexpected block "body" on line 5 of \src\dynamic\views\index.jade. This block is never used. This warning will be an error in v2.0.0
我的src\dynamic\views\index.jade
:
extends _includes/head/head block head title Skool - On Our Way! block body extends _includes/navbars/topNav
_includes/navbars/topNav.jade
文件只是一个基本的 jade 文件,描述了一个简单的 bootstrap 导航栏,所以我将省略它。
_includes/head/head
:
doctype html html head link(rel="styleSheet" href="css/main.css") script(src="js/app.js") block head body block body
现在当我访问localhost:3000
时,迎接我的是我编译好的jade文件,除了<head>
元素是空的,所以没有css链接!检查控制台日志我看到前面提到的 error/warning.
我做错了什么?
非常感谢 @Molda 为我指明了正确的方向。 (S)他说:
I think that you should only use extends once in your view. Use include for topNav.
所以我一替换那个扩展它就起作用了,我的 <head>
元素不再是空的。
现在我找不到任何记录 "you can only use extends
once" 规则的内容,但据我所知,只使用了最后一个扩展。