本文介绍了Mixin 声明没有主体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习 Wes-bos Learn 节点课程.我负责保存 store 和使用 mixins.当我编写 mixins 并运行我的应用程序时,它会出现此错误.
I am doing the Wes-bos Learn node course.I am on the part of saving stores and using mixins. When I write mixins and run my app it gives this error.
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)
This is the file in 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文件夹中的文件
This is the file in views folder
extends layout
include mixins/_storeForm
block content
.inner
h2= title
+storeForm({name:'dkjd'})
我是 nodejs/pug/express 的新手.这段代码有什么问题.给定视频中的这段代码工作正常,但在我的桌面上无效.
I am new to nodejs/pug/express. What is wrong with this code. This code in the given video works fine but not on my desktop.
推荐答案
在你的 mixin storeForm
中,你需要再次缩进 form
和它的子元素.像这样:
Inside your mixin storeForm
, you need to indent form
and its children once more. Like so:
mixin storeForm(store = {})
form(action="/add" method="POST" enctype = "multipart/form-data" class="card")
label(for="name") name
input(type="text" name="name")
这篇关于Mixin 声明没有主体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!