我想在Ajax调用之后呈现一个模板。
我的代码是:
index.pug
include form.pug
+list('style')
form.pug
mixin list(style)
p(class=style) my form我想在点击按钮后添加form.pug,所以
我的ajax调用是:
$.ajax({
url: "/myroute",
method: "POST",
data: msgObj,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
datatype: "json",
success: function (msg) {
div.prepend(msg.template)
},
});/myroute (服务器节点)是:
const pug = require('pug');
var template = pug.renderFile('Path/form.pug');
res.send({"template":template,"style":"new_style"});单击该按钮后,我的模板不显示。在我删除了mixin之后,一切都正常了,但我需要在模板生成过程中传递一个参数
发布于 2021-06-17 00:08:50
在页面中的某个地方调用mixin,在AJAX调用之后在DOM中选择它,并在前置它之前填充所需的值。
https://stackoverflow.com/questions/67628646
复制相似问题