gpt4 book ai didi

node.js - Mixin 声明没有主体

转载 作者:太空宇宙 更新时间:2023-11-03 23:24:01 24 4
gpt4 key购买 nike

我正在学习 Wes-bos Learn Node 类(class)。我负责保存存储并使用 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")

关于node.js - Mixin 声明没有主体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46528783/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com