老师这哪里错了啊 为什么控制台一直报错
来源:4-2 父子组件间的数据传递
ray城市之光
2020-01-17
2回答
-
Dell
2020-01-22
你把报错信息发上来
00 -
ray城市之光
提问者
2020-01-17
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>父子组件的数据传递</title>
<script src="vue.js"></script>
</head>
<body>
<div id="root">
<counter :count="1" @inc="handleIncrease"></counter>
<counter :count="2" @inc="handleIncrease"></counter>
<div>{{total}}</div>
</div>
<script>
var counter = {
props:['count'],
data:function () {
return{
number:this.count
}
},
template:'<div @click="handleClick">{{number}}</div>',
methods:{
handleClick:function () {
this.number = this.number + 2;
thi.$emit('inc',2)
}
}
};
var vm=new Vue({
el:"#root",
data:{
total:3
},
components:{
counter:counter
},
methods:{
handleIncrease:function (step) {
this.total += step;
}
}
})
</script>
</body>
</html>022020-02-07
相似问题