From 3c23590bcb14c505277d4423ed4d7584a6b104ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Tue, 7 Aug 2018 19:10:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=AF=E7=94=B1=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E4=B8=8D=E8=83=BD=E8=A7=A6=E5=8F=91onload=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/router/index.js b/src/router/index.js index 049b8fd..ac70a37 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -63,7 +63,6 @@ class Router { let path = mode === 'hash' ? location.hash : location.pathname path = path.replace(prefix, '').trim() - if (ev.type === 'load') { this.go(path) // hash模式要手动触发一下路由检测 @@ -80,6 +79,9 @@ class Router { } }) + // 部分情况下, 这里的onload没有触发, 需要手动再触发一下 + Anot.fireDom(window, 'load') + //劫持页面上所有点击事件,如果事件源来自链接或其内部, //并且它不会跳出本页,并且以"#/"或"#!/"开头,那么触发go方法 Anot.bind(document, 'click', ev => {