站内搜索:
首页 >> 前端 >> 内容
$emit()括号里面的引号不是常用的单引且会报错

时间:2018/6/26 16:23:52

为什么说$emit()括号里面的引号不是常用的单引?

<p id="app" >  
      <p :style="{ fontSize: postFontSize + 'px' }">  
          <blog  
                  v-for="post in posts"  
                  v-bind:key="post.id"  
                  v-bind:post="post"  
                  v-on:enlarge-text="postFontSize-=10"  
          ></blog>  
      </p>  
  </p>  
  
  <script src="js/vue.js"></script>  
  <script>  
  
      Vue.component('blog',{  
          props:['post'],  
          template:'<p class="content"><h3><button v-on:click="$emit(`enlarge-text`)"> Enlarge text </button><h1>{{ post.name}}</h1></p>'  
      })  
  
      new Vue({  
          el:'#app',  
          data:{  
              posts:[  
                  { id:1, title:'jack',name:'sjemguamg'},  
                  { id:2, title:'zhangsan',name:'xingcheng'}  
              ],  
              postFontSize:40  
          }  
      })  
  
  </script>  

括号里面的引号要是用单引号('')会报错,用这个(``)不报错

  • 上一篇:分享一下css图像拼合技术
  • 下一篇:localStorage todoList 的demo分享
  • 返回顶部