- Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "show"
- 翻译:避免直接改变道具,因为每当父组件重新呈现时,道具的值会被覆盖。 相反,应根据道具的值使用数据或计算属性。 道具变异:“show”
- 用监听的方式去赋值解决
<van-popup v-model="isShow" :style="{height: '80%' }" :close-on-click-overlay="true"
close-icon-position="top-left">
</van-popup>
data() {
return {
isShow: "",
}
}
props: {
show: Boolean,
},
watch:{
show(val) {
this.isShow = val
},
isShow(val) {
if(!val) {
this.$emit('handleClose', val)
}
}
},