浏览代码

MessageBox: wrap hashchange listener in nextTick (#11200)

hetech 7 年之前
父节点
当前提交
b79a98c7e0
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      packages/message-box/src/main.vue

+ 5 - 3
packages/message-box/src/main.vue

@@ -273,9 +273,11 @@
     },
 
     mounted() {
-      if (this.closeOnHashChange) {
-        window.addEventListener('hashchange', this.close);
-      }
+      this.$nextTick(() => {
+        if (this.closeOnHashChange) {
+          window.addEventListener('hashchange', this.close);
+        }
+      });
     },
 
     beforeDestroy() {