サマリー:兩個vue整數(shù)相加 結(jié)果自動更新<script> new Vue({ el:"#id", data:{ onename:"&quo
兩個vue整數(shù)相加 結(jié)果自動更新
<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>
添削の先生:查無此人添削時間:2019-05-05 09:46:01
先生のまとめ:完成的不錯。懂得把數(shù)字先強制類型。繼續(xù)加油。