abstract:两个vue整数相加 结果自动更新<script> new Vue({ el:"#id", data:{ onename:"&quo
两个vue整数相加 结果自动更新
<script>
new Vue({
el:"#id",
data:{
onename:"",
twoname:"",
sum:"",
},
watch:{
onename:function () {
if(this.twoname.length==0){
this.sum='';
}else{
this.sum=Number(this.onename)+Number(this.twoname);
}
},
twoname:function () {
if (this.onename.length==0){
this.sum='';
}else{
this.sum=Number(this.twoname)+Number(this.onename);
}
}
}
})
</script>
Correcting teacher:查无此人Correction time:2019-05-05 09:46:01
Teacher's summary:完成的不错。懂得把数字先强制类型。继续加油。