父组件给子组件传参时,该参数为父组件再前面一个页面路由跳转接受的参数时,传给子组件,子组件接受不到。
父组件:
<Inference :visitId="visitId"></Inference>
mounted(){
this.patientId = this.$route.query.patientId;
this.visitId = this.$route.query.visitId;
},
子组件:
props:{
sendIndex:Number,
visitId:Number,
inferenceData:Array
},
mounted() {
console.log(this.visitId)//为undefined
},
解决办法:
在父组件created生命周期中调用
created(){
this.patientId = this.$route.query.patientId;
this.visitId = this.$route.query.visitId;
},