优化路由检测, 路由不存在时也触发回调, 行为与vue-router保持一致
parent
fc20ea24d4
commit
9c9561cb1c
|
@ -23,6 +23,7 @@ class Router {
|
|||
|
||||
#ready = false
|
||||
#route = Object.create(null)
|
||||
#tmp = null
|
||||
|
||||
#beforeEach
|
||||
|
||||
|
@ -133,7 +134,6 @@ class Router {
|
|||
this.#exec(next)
|
||||
})
|
||||
}
|
||||
|
||||
return this.#exec(next)
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +142,11 @@ class Router {
|
|||
$view.current = route.name
|
||||
this.#route = { path, name: route.name, params: {}, query: {} }
|
||||
this.#exec(this.#route)
|
||||
} else {
|
||||
if (this.#tmp) {
|
||||
this.#exec(this.#tmp)
|
||||
this.#tmp = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,6 +220,8 @@ class Router {
|
|||
return
|
||||
}
|
||||
|
||||
this.#tmp = obj
|
||||
|
||||
if (this.type === MODE_HASH) {
|
||||
if (replace) {
|
||||
location.replace(path.replace(/^\//, '#/'))
|
||||
|
|
Loading…
Reference in New Issue