我正在上Wes-bos学习节点课程,我在保存商店和使用Mixins方面。当我编写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")




这是views文件夹中的文件

extends layout

include mixins/_storeForm

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


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

最佳答案

在您的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")

10-08 14:44