From e38f1c51dc8833c16823a944e6d0fd20a90d321a Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 15 Nov 2023 18:27:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B7=AF=E7=94=B1=E6=A3=80?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/router/router-engine.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index beb35f8..78fdab8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wkitd", - "version": "1.3.0", + "version": "1.3.1", "type": "module", "main": "dist/index.js", "files": [ diff --git a/src/router/router-engine.js b/src/router/router-engine.js index a4b0686..f4d0bf7 100644 --- a/src/router/router-engine.js +++ b/src/router/router-engine.js @@ -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 }