父组件
<infcom :infdata="infDW"></infcom>
computed: {
infDW() {
return this.infData
}
}
methods: {
getIData() {
接口请求 1分钟返回成功
if(res.code == '200'){
this.infData = res.data
console.log(this.infData)
}
}
}
mounted() {
this.getIDate()
}
子组件
watch: {
infdata(){
console.log(this.indata)
}
// 或者
infdata:{
deep:true,
handler(n,o) {
console.log(n.0)
}
console.log(this.indata)
}
}
父组件接口请求成功可以打印出数据
子组件的watch就没有执行
请问一下有哪里写错了吗?
首先,props可以做成动态的。
想要做边际影响,可以设置props的watch来获知变动。