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