浏览代码

Merge pull request #11 from wenhanhan/master

fix-bug -- 使用TreeSelect组件后,重置按钮无法置空该组件值
若依 3 年之前
父节点
当前提交
9f1030d222
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      src/components/TreeSelect/index.vue

+ 3 - 1
src/components/TreeSelect/index.vue

@@ -82,13 +82,15 @@ const defaultExpandedKey = ref([]);
 function initHandle() {
   nextTick(() => {
     const selectedValue = valueId.value;
-    if(selectedValue !== null && typeof (selectedValue) !== "undefined"){
+    if(selectedValue && selectedValue !== null && typeof (selectedValue) !== "undefined"){
       const node = proxy.$refs.selectTree.getNode(selectedValue)
       if (node) {
         valueTitle.value = node.data[props.objMap.label]
         proxy.$refs.selectTree.setCurrentKey(selectedValue) // 设置默认选中
         defaultExpandedKey.value = [selectedValue] // 设置默认展开
       }
+    }else{
+      clearHandle()
     }
   })
 }