我想在我的pug文件中插入一个HTML元素。问题是,当我尝试在pug文件中插入一个元素时,如下所示:
$('.section-reviews').html('h1 Johann Sebastian Bach');或者插入一个混合:
$('.section-reviews').html('+reviewPublish()');我不工作。它将元素作为文本插入,而不是HTML元素。我该如何解决这个问题?
发布于 2020-07-18 04:01:58
https://github.com/PythonLinks/pug/blob/master/README.md#installation-on-the-client
“如果你想在浏览器中编译Pug模板,你需要在浏览器中包含Pug。这是最新版本的Pug for the browser in standalone form。但是,它只支持最新的浏览器,而且是一个大文件,编译速度相对较慢,所以建议只有开发人员这样做,然后保存并提供生成的javascript。”
const pug = require('pug');
$(function() {
$('#content').html(pug.compile(`
mixin pet(name)
li.pet= name
ul
+pet('cat')
+pet('dog')
+pet('pig')
`));
});<script src="https://pugjs.org/js/pug.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="content"></div>
https://stackoverflow.com/questions/62953493
复制相似问题