Forráskód Böngészése

fix: 修复首次打开对话框时表格清空选择状态的问题

xieyong 1 hete
szülő
commit
0969a71a3e
1 módosított fájl, 6 hozzáadás és 3 törlés
  1. 6 3
      src/components/user-select/user-select.vue

+ 6 - 3
src/components/user-select/user-select.vue

@@ -181,11 +181,14 @@
           this.radio = item.id;
         }
         this.currentIndex = index;
+        // 先亮起弹窗再排 nextTick:首次打开时对话框内容尚未挂载,
+        // 否则 clearSelection 执行到 $refs.table 时还是 undefined
+        this.visible = true;
         this.$nextTick(() => {
-          this.$refs.table.clearSelection();
+          if (this.$refs.table) {
+            this.$refs.table.clearSelection();
+          }
         });
-
-        this.visible = true;
       },
 
       /* 表格数据源 */