最近用wangEdiotr的时候,会触及到一个页面会用到了两个编辑框来回切换的效果,文字会多切换回显会报错,网上搜了很多方法没解决,突然想起来了以前使用img解决的方法就是添加一个key值,就可以解决,
<WangEditor v-model:detail="selectedContent" :height="'380px'" :key="selectedContent" />
我的selectedContent绑定的是计算属性,因为会切换数据。
const selectedContent = computed({
get: () => {
if (state.selected >= 0 && state.selected < state.hospitalInfo.otherInfoList?.length) {
return state.hospitalInfo.otherInfoList[state.selected].content;
}
return ""
},
set: (value) => {
if (state.selected >= 0 && state.selected < state.hospitalInfo.otherInfoList?.length) {
state.hospitalInfo.otherInfoList[state.selected].content = value;
}
},
})