我正在使用 Vue 生成一些 html 模板,我需要按照下面的代码包含 html 条件注释。
var productTemplate = new Vue({
el: '#myApp'
});
<script src="https://unpkg.com/[email protected] /cdn-cgi/l/email-protection/dist/vue.js"></script>
<div id="myApp">
<div class="some-content">
This is some content
</div>
<!--[if mso]>
<div>
this div will only be shown if the condition in the comment is true, in this case the condition is:
if ( mso (microsoft office) == the html rendering engine) {
show the html code between the [if mso] and the [endif]
}
</div>
<![endif]-->
<div class="some-other-content">
This is some content
</div>
</div>
但是,当我在浏览器中打开 html 页面时,条件注释之间的 html 代码被完全删除,即使我实际上需要它在那里。
如何让 Vue 在模板视图中包含这些注释?
在 Vue 2.4.0+ 中,您可以设置comments https://v2.vuejs.org/v2/api/#comments选项true
如果您想在组件模板中保留注释,请在组件内部。
var productTemplate = new Vue({
comments: true, // <-- Add this
el: '#myApp'
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)