在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ Vuejs中使用component無法解析template的button標(biāo)簽

Vuejs中使用component無法解析template的button標(biāo)簽

如題,template中的button標(biāo)簽無法顯示、
圖片描述

HTML代碼如下

  <div id="app">
        <counter></counter>
        <counter></counter>
        <counter></counter>
    </div>
    <template id="counter-temp">
        <h1>Hello Vuejs!!</h1>
        <button>{{count}}</button>
    </template>

JS代碼如下

Vue.component('counter',{
       template:'#counter-temp',
       
       data: function () {
        return {count: 0};
       }
      });
     new Vue ({
         el: '#app',
     });
回答
編輯回答
遺莣

vue的組件模板要求是單根,你的counter-temp不是單根,在h1和button外面套一個div就可以了。

<template id="counter-temp">
 <div>
  <h1>Hello Vuejs!!</h1>
  <button>{{count}}</button>
 </div>
</template>
2017年8月2日 16:18