🐛(component): cascader组件 外部清空modelValue内部displayValue不清空问题

This commit is contained in:
0o张不歪o0
2022-09-21 09:52:57 +08:00
parent 85a7217c47
commit 8928f341b7
2 changed files with 18 additions and 0 deletions

View File

@@ -111,6 +111,14 @@ watch(
initTreeData();
}
);
watch(
()=>props.modelValue,
()=>{
if(props.modelValue===null||props.modelValue===''){
onClear();
}
}
);
const treeData = ref<any>([]);
const initTreeData = () => {
@@ -266,6 +274,7 @@ const dropDownDisabled = ref(false);
//清除事件
const onClear = () => {
displayValue.value='';
dropDownDisabled.value = true;
let arr = JSON.parse(JSON.stringify(treeData.value));
for (let index = 0; index < arr.length; index++) {