由于我的子组件在弹窗里面,所以弹窗关闭的时候并没有销毁组件,这就导致我每次再次点击弹窗的时候数据没更新,万般无奈想到了这个办法,下面是代码
父组件代码:
data(){
return {
hackReset = true,
}
}
<temFontEditor v-if="hackReset" ref="temFontEditor" :json="fontEditorJson" :fontEditorWidth="fontEditorWidth" :fontEditorHeight="fontEditorHeight" :bgImgUrl="childViewBgImg"></temFontEditor>
最后在你需要的地方:
// 手动销毁组件
this.hackReset = false;
// 手动创建组件
this.$nextTick(() =>{
this.hackReset = true;
})