vue渲染模板时怎么保留模板中的HTML注释呢?
发布于 2021-01-11 17:03:12
关注者
0
被浏览
515
6 个回答
-
<template comments> <!--我是注释内容--> </template>
<script> export default { comments: true; } </script>
-
Vue默认舍弃注释,可以通过设置comments来开启,相关文档
<template comments> <div> <!--我是注释内容--> </div> </template>
注释一定要在根元素之内
<template comments> <!--我是注释内容--> <div></div> </template>
这样注释是不生效的。这是vue-loader提供的支持
或者
new Vue({ el: "#app", comments: true });
注意:在单文件组件设置是不生效的
<script> export default { comments: true } </script>
相关issue
-
<template comments> ... </template>
-
... <script> import... export default{ comments: true, ... } </script>