Vue html comment handling(Vue html 注释处理)
问题描述
我正在使用 Vue 生成一些 html 模板,我需要按照下面的代码包含 html 条件注释.
var productTemplate = new Vue({埃尔:'#myApp'});
<script src="aHR0cHM6Ly91bnBrZy5jb20vdnVlQDIuNS44L2Rpc3QvdnVlLmpz"></脚本><div id="myApp"><div class="一些内容">这是一些内容</div><!--[if mso]>只有当评论中的条件为真时才会显示此 div,在这种情况下,条件是:if ( mso (microsoft office) == html 渲染引擎) {显示 [if mso] 和 [endif] 之间的 html 代码}</div><![endif]--><div class="其他内容">这是一些内容</div></div>
但是当我在浏览器中打开我的 html 页面时,条件注释之间的 html 代码被完全删除,即使我确实需要它.
如何让 Vue 在模板视图中包含这些注释?
在 Vue 2.4.0+ 中,你可以设置 comments
如果你想在组件的模板中保留注释,则在组件内设置 true
选项.
var productTemplate = new Vue({comments: true,//<-- 添加这个埃尔:'#myApp'});
I'm using Vue to produce some html template, I need to include the html conditional comments as per code below.
var productTemplate = new Vue({
el: '#myApp'
});
<script src="aHR0cHM6Ly91bnBrZy5jb20vdnVlQDIuNS44L2Rpc3QvdnVlLmpz"></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>
But when I open my html page in the browser the html code between the conditional comment is completely removed even though I actually need it to be there.
How can I make Vue include these comments in the template's view?
In Vue 2.4.0+, you can set the comments
option to true
inside the component if you want to preserve comments in the component's template.
var productTemplate = new Vue({
comments: true, // <-- Add this
el: '#myApp'
});
这篇关于Vue html 注释处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Vue html 注释处理


- addEventListener 在 IE 11 中不起作用 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 400或500级别的HTTP响应 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- Fetch API 如何获取响应体? 2022-01-01