注意:前提是你的子组件已经在父组件中引入并使用
1.在父组件中的子组件标签绑定自定义事件
<areaselect @returnDat='returnDate_1' @returnDat_2='returnDate_2'></areaselect>
2.在methods里边写上对应的自定义方法
returnDate_1(val){
this.contact.four_select=val
},
returnDate_2(val){
this.contact.four_address=val
},
3.在子组件模板中绑定触发传递参数的事件
<picker class="select-item" mode="multiSelector" :range="newProvinceDataList" :value="multiIndex"
@change="pickerChange" @columnchange="pickerColumnchange"><view class="titles">
<view class="">
<text class="uni-input" :style="{'color':select=='请选择'?'#C0C4CC':'#303133',}">{{select}}</text>
</view>
<u-icon color="#C0C4CC" name="arrow-down"></u-icon>
</view>
</picker>
<view class="topic_input" style="padding: 0;">
<input @blur="sendaddress" type="text" v-model="send_address.detail" placeholder-style="color:#C0C4CC;font-size:28upx" value="" placeholder="详细地址" />
</view>
4.子组件中写上对应的methods方法:
pickerChange() {
this.$emit("returnDat","值1")//传递的值
},
sendaddress(){
this.$emit("returnDat_2","值2")
},
总结 :子传父主要通过绑定自定义事件 然后通过$emit触发传值