如何在vue.js文件中注释代码? [英] How to comment code in a vue.js file?

查看:1488
本文介绍了如何在vue.js文件中注释代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在vue.js文件中插入注释以供将来参考,但是我在文档中找不到您的操作方式.

I have the need to insert a comment inside a vue.js file for future references, but I don't find how you do this in the docs.

我尝试了///**/{{-- --}}{# #},但是它们似乎都不起作用.

I have tried //, /**/, {{-- --}}, and {# #}, but none of them seem to work.

我正在使用Laravel的刀片.这就是sample_file.vue:

I am using Laravel's blade. So this is the 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> 

有人知道如何插入注释和/或如何注释代码段吗?

Does anyone know how to insert a comment and / or how to comment pieces of code?

推荐答案

您希望根据情况使用<template>标记中的标准HTML注释.它们也会从输出中删除,这很好.

You'd want to use standard HTML comments in the <template> tag in your situation. They'll be stripped from the output as well which is nice.

<!-- Comment -->

这篇关于如何在vue.js文件中注释代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆