This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

修复路由可能不能触发onload的bug

old
宇天 2018-08-07 19:10:24 +08:00
parent bdb61f4f7a
commit 3c23590bcb
1 changed files with 3 additions and 1 deletions

View File

@ -63,7 +63,6 @@ class Router {
let path = mode === 'hash' ? location.hash : location.pathname let path = mode === 'hash' ? location.hash : location.pathname
path = path.replace(prefix, '').trim() path = path.replace(prefix, '').trim()
if (ev.type === 'load') { if (ev.type === 'load') {
this.go(path) this.go(path)
// hash模式要手动触发一下路由检测 // hash模式要手动触发一下路由检测
@ -80,6 +79,9 @@ class Router {
} }
}) })
// 部分情况下, 这里的onload没有触发, 需要手动再触发一下
Anot.fireDom(window, 'load')
//劫持页面上所有点击事件,如果事件源来自链接或其内部, //劫持页面上所有点击事件,如果事件源来自链接或其内部,
//并且它不会跳出本页,并且以"#/"或"#!/"开头那么触发go方法 //并且它不会跳出本页,并且以"#/"或"#!/"开头那么触发go方法
Anot.bind(document, 'click', ev => { Anot.bind(document, 'click', ev => {