1.父组件
代码如下(示例):
<el-button @click="handleClick(scope.row.equipmentId)" type="text" size="small">查看</el-button>
<add-contact :eqId = 'eqId'></add-contact>
<script>
import addContact from './addContact.vue'
export default {
name: "addDevice",
data() {
return {
eqId:''
}
},
components:{
addContact
},
methods:{
handleClick(id){
// console.log(id)
this.eqId = id
this.dialogVisible = true
},
}
}
</script>
2.子组件
代码如下(示例):
<script>
export default {
props:['eqId'],
watch:{
eqId(eqId){
// console.log(this.eqId,'789')
this.getEquipmentFun(eqId);
}
},
created(){
this.getEquipmentFun(this.eqId);
}
}
</script>