<!DOCTYPE?html>
<html?lang="en">
<head>
????<meta?charset="UTF-8">
????<title>Title</title>
</head>
<body>
<div?id="app">
????<counter></counter>
????<counter></counter>
</div>
????<template?id="counter-template">
??????????<a>點(diǎn)我</a>
????????<button?@click="count+=1">點(diǎn)我{{count}}</button>
????</template>
<script?src="Vue.min.js"></script>
<script>
?Vue.component('counter',{
????????template:'#counter-template',
?data:function(){
????????????return{count:0};
?}
????});
?new?Vue({
????????el:'#app'
?})
</script>
</body>
</html>為什么效果出現(xiàn)后Vue.component只能獲得ID里的第一段代碼?就是只能顯示出來兩個(gè)a標(biāo)簽里的內(nèi)容,要是把下面的button放到前面,就只顯示button而不顯示a標(biāo)簽里的內(nèi)容了
Vue.component
Ximoo
2018-10-11 08:46:35