From 4228a62d86ca8dbec05e5c71a3edc93d1664ce82 Mon Sep 17 00:00:00 2001
From: icssoa <615206459@qq.com>
Date: Tue, 28 Oct 2025 11:31:49 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20router.query=20=E5=8F=96?=
=?UTF-8?q?=E5=80=BC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
cool/router/index.ts | 14 +++++++++++---
pages/demo/other/router/query.uvue | 7 ++++++-
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/cool/router/index.ts b/cool/router/index.ts
index fb62883..c46a81f 100644
--- a/cool/router/index.ts
+++ b/cool/router/index.ts
@@ -10,7 +10,9 @@ import {
toArray,
map,
debounce,
- nth
+ nth,
+ assign,
+ parse
} from "../utils";
// 路由信息类型
@@ -36,11 +38,16 @@ type Events = {
export class Router {
private eventsMap = {} as Events; // 事件存储
- // 获取缓存的路由参数
+ // 获取传递的 params 参数
params() {
return (storage.get("router-params") ?? {}) as UTSJSONObject;
}
+ // 获取传递的 query 参数
+ query() {
+ return this.route()?.query ?? {};
+ }
+
// 获取默认路径,支持 home 和 login
defaultPath(name: "home" | "login") {
const paths = {
@@ -82,7 +89,8 @@ export class Router {
// #endif
// 获取页面 query 参数
- const query = (get(e, "options") ?? {}) as UTSJSONObject;
+ // @ts-ignore
+ const query = e.options;
return {
path,
diff --git a/pages/demo/other/router/query.uvue b/pages/demo/other/router/query.uvue
index de14587..50c79ea 100644
--- a/pages/demo/other/router/query.uvue
+++ b/pages/demo/other/router/query.uvue
@@ -15,7 +15,7 @@