From d95f1bc9fc0b06bc58e6d7dbd9244dccdc26522e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Tue, 7 Aug 2018 19:56:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B7=AF=E7=94=B1=E8=A7=84?= =?UTF-8?q?=E5=88=99=E7=9B=91=E5=90=AC=E4=B8=8Ewindow.onload=E7=9A=84?= =?UTF-8?q?=E6=AC=A1=E5=BA=8F=E9=97=AE=E9=A2=98=E5=AF=BC=E8=87=B4=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=B2=A1=E8=83=BD=E6=AD=A3=E5=B8=B8=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index ac70a37..22c1134 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -79,9 +79,6 @@ class Router { } }) - // 部分情况下, 这里的onload没有触发, 需要手动再触发一下 - Anot.fireDom(window, 'load') - //劫持页面上所有点击事件,如果事件源来自链接或其内部, //并且它不会跳出本页,并且以"#/"或"#!/"开头,那么触发go方法 Anot.bind(document, 'click', ev => { @@ -224,6 +221,10 @@ class Router { } else { this.__add__(rule, callback) } + // 因为先初始化,才开始监听路由规则 + // 所以会导致wondow load的时候, 规则还没生效, 而生效之后,load已经结束 + // 所以这里需要手动再触发一次load + Anot.fireDom(window, 'load') } }