优化路由检测
parent
66971278a2
commit
e38f1c51dc
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wkitd",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
|
|
|
@ -99,7 +99,7 @@ class Router {
|
|||
let path = isHash
|
||||
? hash
|
||||
: location.href.replace(location.origin, '').replace(hash, '')
|
||||
let query
|
||||
let query = ''
|
||||
|
||||
if (path.includes('?')) {
|
||||
;[path, query] = path.split('?')
|
||||
|
@ -107,6 +107,11 @@ class Router {
|
|||
path = path.replace(PREFIX_REGEXP, '/')
|
||||
|
||||
if (!$view || path === this.#route.path) {
|
||||
// query不同, 只更新query
|
||||
if (query !== object2query(this.#route.query)) {
|
||||
this.#route.query = query2object(query)
|
||||
return this.#broadcast()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue