Mixin没有身体宣布

时间:2017-10-02 15:34:32

标签: node.js pug

我正在做Wes-bos Learn节点课程。我正在保存商店和使用mixin。当我编写mixins并运行我的应用程序时,会出现此错误。

Error: C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\views\mixins\_storeForm.pug:1:1
> 1| mixin storeForm(store = {})
   -------^
2| form(action="/add" method="POST" enctype = "multipart/form-data" class="card")
3| label(for="name") name
4| input(type="text" name="name")

Mixin storeForm declared without body
at makeError (C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\node_modules\pug-error\index.js:32:13)
at Parser.error (C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\node_modules\pug-parser\index.js:53:15)
at Parser.parseMixin (C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\node_modules\pug-parser\index.js:871:12)
at Parser.parseExpr (C:\Users\ATUL\Downloads\Learn-Node-master\Learn-Node-master\starter-files\node_modules\pug-parser\index.js:204:21)

这是Mixins(_storeForm.pug)

中的文件
mixin storeForm(store = {})
form(action="/add" method="POST" enctype = "multipart/form-data" class="card")
  label(for="name") name
  input(type="text" name="name")

这是视图文件夹中的文件

extends layout

include mixins/_storeForm

block content 
  .inner
    h2= title 
    +storeForm({name:'dkjd'})

我是nodejs / pug / express的新手。这段代码有什么问题。给定视频中的此代码工作正常但不在我的桌面上。

1 个答案:

答案 0 :(得分:1)

在mixin storeForm中,您需要再次缩进form及其子级。像这样:

mixin storeForm(store = {})
    form(action="/add" method="POST" enctype = "multipart/form-data" class="card")
        label(for="name") name
        input(type="text" name="name")