2016-12-19 4 views
11

将来の参照のためにvue.jsファイル内にコメントを挿入する必要がありますが、ドキュメントでこれを行う方法はわかりません。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> 

誰でもコメントを挿入する方法および/またはコードの一部をコメントする方法を知っていますか?

+1

あなたは複数行コメントを探しているなら、標準のHTMLコメントは動作します: ''しかし、あなたはインラインコメントを探しているようですね? – Adam

+0

ああ、私はそれを忘れてしまった。実際には 'HTML'コードです! Thnx – Pathros

答えて

23

状況に応じて、<template>タグで標準のHTMLコメントを使用したいと考えています。彼らは出力からも剥奪され、いいですね。

<!-- Comment --> 
+0

これはトリックをした – Pathros

0

私はVue.jsのnoobですが、コードはjavascriptなので動作するはずです。 ドキュメントを見る私はこの例を見つけます:https://vuejs.org/v2/examples/todomvc.html JavaScriptの最初の2行を見ると、コメントが表示されます//。

-1

Bill Criswell氏は、HTMLコメント構文を使用できると述べています。

<!-- Comment --> 

しかし、それはあまりにもテンプレートタグの外に動作しますが、 comment.vue

<!-- Testing comments, this will work too. --> 

<template> 
    <!-- This will work too --> 

    <div> 
     <!-- Html Comments --> 
     Hello There! 
    </div> 
</template> 

<style><style> 

<!-- Commenting here --> 

<script> 
</script> 
+0

この結果、Vue 2.5.13で「予期しないトークン(1:1)」が発生します。 –

関連する問題