我需要在vue.js文件中插入注释以备将来参考,但我在文档中找不到如何实现它。
我尝试过//
、/**/
、{{-- --}}
和{# #}
,但似乎都不起作用。
我正在使用Laravel的刀片引擎。所以这是sample_file.vue
文件:
<template>
<div class="media">
<like-button :post="post" v-if="post.likedByCurrentUser === false && "></like-button> {{--I want to comment this but I get an error from the gulp watch: post.canBeLikedByCurrentUser === true--}}
<div class="media-left">
<a href="#">
<img class="media-object" v-bind:src="post.user.avatar" v-bind:title="post.user.name + ' image from Gravatar'">
</a>
</div>
<div class="media-body">
<strong>{{ post.user.name }}</strong>
<p>{{post.body}}</p>
<p>{{post.likeCount}} {{ pluralize('like', post.likeCount) }}</p>
</div>
</div>
</template>
有人知道如何插入注释和/或如何对代码片段进行注释吗?
<!-- -->
。但是听起来你正在寻找内联注释? - Adam{{! 这样的注释 }}
和{{!-- 包含双括号 {{like this}} 的注释 --}}
。这些在输出时不会被呈现,与<!-- html 注释 -->
不同,它们会被呈现。我已经尝试在Vue中使用{{! ... }}
和{{!-- ... --}}
,但很遗憾它们并未被支持。如果有用户遇到此问题,您是否考虑将它们添加到您的问题中? - chharvey