更新至父子组件互相通信

This commit is contained in:
Code12121 2022-10-31 18:16:42 +08:00
parent 2a1dcc8dfb
commit e38b5bbfae
1 changed files with 6 additions and 4 deletions

View File

@ -15,7 +15,7 @@
3、$emit所发射的内容必须要由父组件的v-on事件所接受
-->
<div id="app" >
<apps :num-befor1="num1" :num-befor2="num2" @this_data_n1="this_num1" @this_data_n2="this_num2"></apps>
<apps :num-befor1="num1" :num-befor2="num2" @this_data_n1="this_num1" @this_data_n2="this_num2" @this_bedata1="this_Data1"></apps>
</div>
<template id="tpl">
<div>
@ -45,10 +45,10 @@
this_num2(val){
this.num2=parseInt(val)
},
this_Data_n2(val){
this.num2=val
this_bedata1(val){
this.num1=val
},
this_Data_n1(val) {
this_bedata2(val) {
this.num1 = val
}
},
@ -81,11 +81,13 @@
this.Data_n1=val.target.value
this.$emit("this_data_n1",this.Data_n1)
this.Data_n2=this.Data_n1*100
this.$emit("this_bedata2", Data_n2)
},
Data_num2(val) {
this.Data_n2 = val.target.value
this.$emit("this_data_n2", this.Data_n2)
this.Data_n1=this.Data_n2/100
this.$emit("this_bedata1", Data_n1)
}
}
}