vitarx-router 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,1399 @@
1
+ import { Computed } from 'vitarx';
2
+ import { Element as Element_2 } from 'vitarx';
3
+ import { HTMLClassProperties } from 'vitarx';
4
+ import { HTMLProperties } from 'vitarx';
5
+ import { HTMLStyleProperties } from 'vitarx';
6
+ import { LazyLoader } from 'vitarx';
7
+ import { RouteLocation as RouteLocation_2 } from '../index.js';
8
+ import { VNode } from 'vitarx';
9
+ import { Widget } from 'vitarx';
10
+ import { WidgetType } from 'vitarx';
11
+
12
+ /**
13
+ * 路由后置钩子
14
+ *
15
+ * 在导航确认后调用
16
+ *
17
+ * @param this - 路由器实例
18
+ * @param to - 即将要进入的目标路由对象
19
+ * @param from - 当前导航正要离开的路由对象
20
+ */
21
+ export declare type AfterEnterCallback = (this: Router, to: ReadonlyRouteLocation, from: ReadonlyRouteLocation) => void;
22
+
23
+ /**
24
+ * 允许的路由小部件联合类型
25
+ *
26
+ * 可以是单个视图组件或命名视图组件的记录
27
+ */
28
+ export declare type AllowedRouteWidget = RouteWidget | NamedRouteWidget;
29
+
30
+ /**
31
+ * 路由前置钩子返回值
32
+ *
33
+ * - boolean: true继续导航,false阻止导航
34
+ * - RouteTarget: 重定向到新的目标
35
+ * - void: 继续导航
36
+ * - Promise: 异步处理,resolve的值同上
37
+ */
38
+ export declare type BeforeEachCallbackResult = boolean | RouteTarget | void | Promise<boolean | RouteTarget | void>;
39
+
40
+ /**
41
+ * 路由前置钩子
42
+ *
43
+ * 在导航确认前调用,可以通过返回false来取消导航
44
+ *
45
+ * @param this - 路由器实例
46
+ * @param to - 即将要进入的目标路由对象
47
+ * @param from - 当前导航正要离开的路由对象
48
+ */
49
+ export declare type BeforeEnterCallback = (this: Router, to: ReadonlyRouteLocation, from: ReadonlyRouteLocation) => BeforeEachCallbackResult;
50
+
51
+ /**
52
+ * 创建内存路由器
53
+ *
54
+ * 不支持浏览器的前进后退等操作,只能通过实例中的方法来管理路由。
55
+ *
56
+ * 你必须调用一次`router.replace(target)`方法来跳转到目标路由。
57
+ *
58
+ * @param {RouterOptions} options - 配置
59
+ * @return {RouterMemory} - 内存路由器实例
60
+ */
61
+ export declare function createRouter(options: RouterOptions & {
62
+ mode: 'memory';
63
+ }): MemoryRouter;
64
+
65
+ /**
66
+ * 创建History路由器
67
+ *
68
+ * 基于History API实现路由功能,支持浏览器前进后退、刷新等操作。
69
+ *
70
+ * 它与`MemoryRouter`路由不同的是,它不需要初始化过后调用`router.replace(target)`方法来替换默认路由,
71
+ * 内部会自动根据`window.location`去匹配路由。
72
+ *
73
+ * @param {RouterOptions} options - 路由配置
74
+ * @return {RouterHistory} - HistoryRouter实例
75
+ */
76
+ export declare function createRouter(options: RouterOptions | (RouterOptions & {
77
+ mode: 'path' | 'hash';
78
+ })): HistoryRouter;
79
+
80
+ /**
81
+ * 定义路由
82
+ *
83
+ * 使用defineRoute定义路由可以获得更好的代码提示。
84
+ *
85
+ * @param {Route} route - 路由配置
86
+ */
87
+ export declare function defineRoute(route: Route): Route;
88
+
89
+ /**
90
+ * 定义路由表
91
+ *
92
+ * 使用defineRoutes定义路由表可以获得更好的代码提示。
93
+ *
94
+ * @param {Route[]} routes - 路由配置表
95
+ */
96
+ export declare function defineRoutes(...routes: Route[]): Route[];
97
+
98
+ /**
99
+ * 动态路由记录
100
+ */
101
+ export declare interface DynamicRouteRecord {
102
+ regex: RegExp;
103
+ route: RouteNormalized;
104
+ }
105
+
106
+ /**
107
+ * hash字符串类型
108
+ *
109
+ * 以#开头的字符串或空字符串
110
+ */
111
+ export declare type HashStr = `#${string}` | '';
112
+
113
+ /**
114
+ * 路由模式
115
+ *
116
+ * - hash: 使用URL hash实现路由
117
+ * - path: 使用HTML5 History API实现路由
118
+ * - memory: 使用内存实现路由
119
+ */
120
+ export declare type HistoryMode = 'hash' | 'path' | 'memory';
121
+
122
+ /**
123
+ * 基于`window.history`实现的路由器
124
+ *
125
+ * 支持浏览器前进、后退、跳转等操作
126
+ */
127
+ export declare class HistoryRouter extends Router {
128
+ constructor(options: RouterOptions<'path' | 'hash'>);
129
+ /**
130
+ * 当前路由目标
131
+ *
132
+ * @returns {RouteTarget} - 包含 index、hash 和 query 的对象
133
+ */
134
+ protected get currentRouteTarget(): MakeRequired<RouteTarget, 'query' | 'hash'>;
135
+ /**
136
+ * window.history
137
+ *
138
+ * @private
139
+ */
140
+ private get webHistory();
141
+ /**
142
+ * @inheritDoc
143
+ */
144
+ go(delta?: number): void;
145
+ /**
146
+ * @inheritDoc
147
+ */
148
+ protected initializeRouter(): void;
149
+ /**
150
+ * @inheritDoc
151
+ */
152
+ protected pushHistory(data: RouteLocation): void;
153
+ /**
154
+ * @inheritDoc
155
+ */
156
+ protected replaceHistory(data: RouteLocation): void;
157
+ /**
158
+ * 保存当前页面滚动位置
159
+ *
160
+ * @private
161
+ */
162
+ private saveCurrentScrollPosition;
163
+ /**
164
+ * 创建历史记录状态
165
+ *
166
+ * 用于在浏览器历史记录中存储路由信息,以支持前进、后退等操作。
167
+ *
168
+ * @param data - 路由数据
169
+ * @param hash - 要替换的哈希值
170
+ * @param query - 要替换的查询参数
171
+ * @private
172
+ */
173
+ private createState;
174
+ /**
175
+ * 处理浏览器历史记录的返回/前进事件
176
+ */
177
+ private onPopState;
178
+ /**
179
+ * 确保路径是 hash 格式
180
+ *
181
+ * @private
182
+ */
183
+ private ensureHash;
184
+ }
185
+
186
+ declare type HttpUrl = `http://${string}`;
187
+
188
+ /**
189
+ * 已初始化的路由配置
190
+ */
191
+ export declare type InitializedRouterOptions = MakeRequired<RouterOptions, Exclude<keyof RouterOptions, 'beforeEach' | 'afterEach' | 'missing'>>;
192
+
193
+ /**
194
+ * 命名的props
195
+ */
196
+ export declare type InjectNamedProps<k extends string = string> = Record<k, InjectProps>;
197
+
198
+ /**
199
+ * 路由参数注入
200
+ */
201
+ export declare type InjectProps = boolean | Record<string, any> | InjectPropsHandler;
202
+
203
+ /**
204
+ * 注入参数处理函数
205
+ *
206
+ * @param {ReadonlyRouteLocation} location 路由匹配的位置信息
207
+ * @return {Record<string, any>} 注入的参数
208
+ */
209
+ export declare type InjectPropsHandler = (location: ReadonlyRouteLocation) => Record<string, any>;
210
+
211
+ /**
212
+ * ## 标记延迟加载
213
+ *
214
+ * 由于直接定义`() => import('./xxx.js')`会导致类型与函数式组件冲突,
215
+ * 在未执行函数之前难以有效判断其类型,所以这里使用Symbol标记懒加载器。
216
+ *
217
+ * @example
218
+ * lazy(() => import('./xxx.js'))
219
+ *
220
+ * @template T - WidgetType
221
+ * @param {LazyLoader<T>} lazyLoader - 函数返回的import即是惰性加载器
222
+ */
223
+ export declare function lazy<T extends WidgetType>(lazyLoader: LazyLoader<T>): LazyLoad<T>;
224
+
225
+ declare const LAZY_LOADER_SYMBOL: unique symbol;
226
+
227
+ declare type LAZY_LOADER_SYMBOL = typeof LAZY_LOADER_SYMBOL;
228
+
229
+ /**
230
+ * 延迟加载/惰性加载
231
+ *
232
+ * 用于实现代码分块和懒加载功能
233
+ */
234
+ export declare interface LazyLoad<T> {
235
+ [LAZY_LOADER_SYMBOL]: boolean;
236
+ (): Promise<{
237
+ default: T;
238
+ }>;
239
+ }
240
+
241
+ /**
242
+ * 路由匹配结果
243
+ */
244
+ export declare type MatchResult = {
245
+ route: RouteNormalized;
246
+ params: Record<string, string> | undefined;
247
+ } | undefined;
248
+
249
+ /**
250
+ * 基于内存实现的路由器
251
+ *
252
+ * 仅支持路由器操作前进、后退、跳转等操作
253
+ *
254
+ * > 注意:不要在浏览器端使用,因为浏览器端有原生的history对象,使用内存模式会和浏览器端的历史记录冲突,导致路由异常。
255
+ */
256
+ export declare class MemoryRouter extends Router {
257
+ protected _history: ReadonlyRouteLocation[];
258
+ protected _pendingGo: number | null;
259
+ constructor(options: RouterOptions<'memory'>);
260
+ private _currentIndex;
261
+ /**
262
+ * 当前历史路由索引
263
+ *
264
+ * @protected
265
+ */
266
+ protected get currentIndex(): number;
267
+ /**
268
+ * @inheritDoc
269
+ */
270
+ go(delta?: number): void;
271
+ /**
272
+ * @inheritDoc
273
+ */
274
+ protected initializeRouter(): void;
275
+ /**
276
+ * 添加历史记录
277
+ */
278
+ protected pushHistory(data: RouteLocation): void;
279
+ /**
280
+ * 替换历史记录
281
+ */
282
+ protected replaceHistory(data: RouteLocation): void;
283
+ /**
284
+ * 更新历史记录
285
+ *
286
+ * @param {RouteLocation} data - 目标路由
287
+ * @param {boolean} isReplace - 是否为替换操作
288
+ * @private
289
+ */
290
+ private _updateHistory;
291
+ }
292
+
293
+ /**
294
+ * 命名的路由视图小部件
295
+ *
296
+ * 用于多视图布局
297
+ */
298
+ export declare type NamedRouteWidget<K extends string = string> = Record<K, RouteWidget>;
299
+
300
+ /**
301
+ * 导航结果
302
+ *
303
+ * 包含导航的状态和相关信息
304
+ */
305
+ export declare interface NavigateResult {
306
+ /**
307
+ * 导航状态
308
+ */
309
+ status: NavigateStatus;
310
+ /**
311
+ * 状态描述
312
+ */
313
+ message: string;
314
+ /**
315
+ * 最终的导航数据
316
+ */
317
+ to: ReadonlyRouteLocation;
318
+ /**
319
+ * 导航完成前的路由数据
320
+ */
321
+ from: ReadonlyRouteLocation;
322
+ /**
323
+ * 如果在守卫过程中被重定向,则为最初的路由目标
324
+ */
325
+ redirectFrom: RouteTarget | undefined;
326
+ /**
327
+ * 捕获到的异常
328
+ */
329
+ error?: unknown;
330
+ }
331
+
332
+ /**
333
+ * 导航结果
334
+ *
335
+ * 枚举值:
336
+ * 0. success: 导航成功
337
+ * 1. aborted: 导航被阻止
338
+ * 2. cancelled: 导航被取消
339
+ * 3. duplicated: 重复导航
340
+ * 4. not_matched: 路由未匹配
341
+ * 5. exception: 捕获到异常
342
+ */
343
+ export declare enum NavigateStatus {
344
+ /**
345
+ * 导航成功
346
+ */
347
+ success = 0,
348
+ /**
349
+ * 导航被阻止
350
+ */
351
+ aborted = 1,
352
+ /**
353
+ * 导航被取消
354
+ *
355
+ * 正在等待中间件处理结果时又触发了新的导航请求
356
+ */
357
+ cancelled = 2,
358
+ /**
359
+ * 重复导航
360
+ */
361
+ duplicated = 3,
362
+ /**
363
+ * 路由未匹配
364
+ */
365
+ not_matched = 4,
366
+ /**
367
+ * 捕获到异常
368
+ */
369
+ exception = 5
370
+ }
371
+
372
+ /**
373
+ * 只读路由位置对象
374
+ */
375
+ export declare type ReadonlyRouteLocation = DeepReadonly<RouteLocation>;
376
+
377
+ /**
378
+ * 只读规范化路由线路配置
379
+ */
380
+ export declare type ReadonlyRouteNormalized = DeepReadonly<RouteNormalized>;
381
+
382
+ /**
383
+ * 重定向处理器
384
+ */
385
+ export declare type RedirectHandler = (this: Router, to: RouteLocation) => RouteTarget | undefined;
386
+
387
+ /**
388
+ * 路由路线配置
389
+ *
390
+ * 该接口定义了应用程序中路由的配置对象的结构它描述了路由如何映射到组件,
391
+ * 以及路由的各种属性和行为
392
+ *
393
+ * @template T - 指定路由组件的类型,必须是 AllowedRouteWidget 的子类型
394
+ */
395
+ export declare interface Route<T extends AllowedRouteWidget = AllowedRouteWidget> {
396
+ /**
397
+ * 路由的路径,用于URL匹配
398
+ *
399
+ * 支持动态路径匹配,如:/user/{id},可选变量:/user/{id?}
400
+ */
401
+ path: RoutePath;
402
+ /**
403
+ * 动态路由匹配模式
404
+ *
405
+ * 默认会继承`RouterOptions.pattern`
406
+ */
407
+ pattern?: Record<string, RegExp>;
408
+ /**
409
+ * 路由的名称,用于识别和引用路由
410
+ */
411
+ name?: string;
412
+ /**
413
+ * 路由对应的视图组件
414
+ *
415
+ * 支持命名视图
416
+ *
417
+ * @example
418
+ * ```ts
419
+ * {
420
+ * path: '/user/{id}',
421
+ * name: 'user',
422
+ * widget: {
423
+ * default: User,
424
+ * detail: UserDetail,
425
+ * }
426
+ * }
427
+ * ```
428
+ */
429
+ widget?: T;
430
+ /**
431
+ * 路由重定向的目标地址或处理函数
432
+ */
433
+ redirect?: RouteTarget | RedirectHandler;
434
+ /**
435
+ * 子路由配置,用于嵌套路由
436
+ */
437
+ children?: Route[];
438
+ /**
439
+ * 路由的元数据,用于存储附加信息
440
+ */
441
+ meta?: RouteMetaData;
442
+ /**
443
+ * 路由的后缀配置,决定是否支持通配符或指定后缀
444
+ *
445
+ * 默认继承`RouterOptions.suffix`
446
+ */
447
+ suffix?: '*' | string | string[] | false;
448
+ /**
449
+ * 需要给路由`Widget`注入的参数
450
+ *
451
+ * 可选值:
452
+ * - `true`:表示仅注入匹配到的动态参数
453
+ * - `false`:表示不注入任何参数
454
+ * - `{key: value}`:表示注入指定参数,其中`key`为参数名,`any`为参数值
455
+ * - `(location: RouteLocation) => {key: value}`:自定义一个处理函数,返回一个对象用于注入参数
456
+ *
457
+ * > 注意:如果是命名视图,则需要以键值对形式传入:{视图名称:injectProps配置}
458
+ *
459
+ * @default true
460
+ */
461
+ injectProps?: (T extends NamedRouteWidget<infer k> ? InjectNamedProps<k> : InjectProps) | boolean;
462
+ /**
463
+ * 路由进入前的钩子函数,用于权限控制或数据预加载
464
+ *
465
+ * 默认继承`RouterOptions.beforeEach`
466
+ */
467
+ beforeEnter?: BeforeEnterCallback;
468
+ /**
469
+ * 路由进入后的钩子函数,用于处理进入路由后的逻辑
470
+ *
471
+ * 默认继承`RouterOptions.afterEach`
472
+ */
473
+ afterEnter?: AfterEnterCallback;
474
+ }
475
+
476
+ /**
477
+ * 路由索引
478
+ *
479
+ * 可以是路径或命名路由
480
+ */
481
+ export declare type RouteIndex = RouterRouteIndexTyped;
482
+
483
+ /**
484
+ * 路由匹配的详情数据
485
+ *
486
+ * 所有和url相关的数据都已`decodeURIComponent`解码
487
+ */
488
+ export declare interface RouteLocation {
489
+ /**
490
+ * 路由索引,调用`push`|`replace`时传入的index
491
+ */
492
+ index: RouteIndex;
493
+ /**
494
+ * 完整的path,包含了query和hash
495
+ */
496
+ fullPath: string;
497
+ /**
498
+ * `index`所带的后缀
499
+ *
500
+ * 如果没有后缀则为空字符串
501
+ */
502
+ suffix: '' | `.${string}`;
503
+ /**
504
+ * 路由路径
505
+ *
506
+ * 如果匹配到路由则为路由的`path`属性
507
+ */
508
+ path: `/${string}`;
509
+ /**
510
+ * URL hash
511
+ */
512
+ hash: HashStr;
513
+ /**
514
+ * 路由参数
515
+ */
516
+ params: Record<string, any>;
517
+ /**
518
+ * URL 查询参数
519
+ */
520
+ query: Record<string, string>;
521
+ /**
522
+ * 路由元数据
523
+ */
524
+ meta: RouteMetaData;
525
+ /**
526
+ * 匹配的路由记录
527
+ *
528
+ * 从根路由开始,到当前路由结束
529
+ */
530
+ matched: RouteNormalized[];
531
+ }
532
+
533
+ /**
534
+ * 命名路由
535
+ *
536
+ * 用于标识路由的唯一名称
537
+ */
538
+ export declare type RouteName = string;
539
+
540
+ /**
541
+ * 规范化路由线路配置
542
+ */
543
+ export declare interface RouteNormalized extends MakeRequired<Route, 'meta' | 'pattern' | 'suffix'> {
544
+ children: RouteNormalized[];
545
+ widget: undefined | Record<string, RouteWidget>;
546
+ injectProps: undefined | InjectNamedProps;
547
+ }
548
+
549
+ export declare interface RouteOptions {
550
+ /**
551
+ * 命名视图
552
+ *
553
+ * @default 'default'
554
+ */
555
+ name?: string;
556
+ }
557
+
558
+ /**
559
+ * 路由路径
560
+ *
561
+ * 必须以/开头的字符串
562
+ */
563
+ export declare type RoutePath = `/${string}`;
564
+
565
+ /**
566
+ * 路由器核心类
567
+ *
568
+ * 继承自 RouterRegistry,负责处理路由导航、历史记录管理、生命周期等核心功能。
569
+ * 采用单例模式,确保全局只有一个路由器实例。
570
+ */
571
+ export declare abstract class Router extends RouterRegistry {
572
+ private _currentTaskId;
573
+ private _taskCounter;
574
+ /**
575
+ * 等待执行的 replace 操作数据
576
+ * 如果不为 null,表示当前有一个等待完成的 replace 导航
577
+ */
578
+ private _pendingReplace;
579
+ /**
580
+ * 等待执行的 push 操作数据
581
+ * 如果不为 null,表示当前有一个等待完成的 push 导航
582
+ */
583
+ private _pendingPush;
584
+ /**
585
+ * 滚动行为处理器
586
+ * 用于自定义路由切换时的滚动行为
587
+ */
588
+ private _scrollBehaviorHandler;
589
+ /**
590
+ * 当前路由数据
591
+ * 包含当前路由的完整信息,如路径、参数、查询字符串等
592
+ */
593
+ private readonly _currentRouteLocation;
594
+ /**
595
+ * 只读路由位置数据
596
+ *
597
+ * @private
598
+ */
599
+ private readonly _readonlyRouteLocation;
600
+ /**
601
+ * 路由器构造函数
602
+ * 初始化路由器并确保单例
603
+ *
604
+ * @param {RouterOptions} options - 路由器配置选项
605
+ * @throws {Error} 如果已存在路由器实例则抛出错误
606
+ */
607
+ protected constructor(options: RouterOptions);
608
+ /**
609
+ * 路由器单例实例
610
+ * 用于全局存储唯一的路由器实例
611
+ */
612
+ private static _instance;
613
+ /**
614
+ * 获取路由器单例实例
615
+ *
616
+ * @throws {Error} 如果路由器未初始化则抛出错误
617
+ * @return {RouterCore} 路由器实例
618
+ */
619
+ static get instance(): Router;
620
+ /**
621
+ * 判断路由器是否初始化完成
622
+ *
623
+ * 如果存在单例则代表初始化完成,没有单例则代表未初始化。
624
+ *
625
+ * @return {boolean} - 如果初始化完成,返回true,否则返回false
626
+ */
627
+ get initialized(): boolean;
628
+ /**
629
+ * 是否运行在浏览器环境
630
+ * 用于区分服务端渲染和客户端渲染
631
+ */
632
+ private _isBrowser;
633
+ /**
634
+ * 是否运行在浏览器端
635
+ */
636
+ get isBrowser(): boolean;
637
+ /**
638
+ * 滚动行为
639
+ * 定义路由切换时的滚动效果
640
+ */
641
+ private _scrollBehavior;
642
+ /**
643
+ * 滚动行为
644
+ *
645
+ * 如果options.scrollBehavior为函数,则scrollBehavior固定为auto'。
646
+ */
647
+ get scrollBehavior(): _ScrollBehavior;
648
+ /**
649
+ * 获取配置
650
+ *
651
+ * @return {Readonly<InitializedRouterOptions>} - 初始化配置
652
+ */
653
+ get options(): Readonly<InitializedRouterOptions>;
654
+ /**
655
+ * 路由器模式
656
+ */
657
+ get mode(): HistoryMode;
658
+ /**
659
+ * 当前路由数据
660
+ *
661
+ * 它是只读的,但它是响应式的,所以你可以在监听其变化。
662
+ *
663
+ * @return {ReadonlyRouteLocation} - 当前路由数据
664
+ */
665
+ get currentRouteLocation(): ReadonlyRouteLocation;
666
+ /**
667
+ * 是否处于等待状态
668
+ *
669
+ * @protected
670
+ */
671
+ protected get isPendingNavigation(): boolean;
672
+ /**
673
+ * 等待替换完成的数据
674
+ *
675
+ * @protected
676
+ */
677
+ protected get pendingReplaceData(): RouteLocation | null;
678
+ /**
679
+ * 等待跳转完成的数据
680
+ *
681
+ * @protected
682
+ */
683
+ protected get pendingPushData(): RouteLocation | null;
684
+ /* Excluded from this release type: routeViewElement */
685
+ /**
686
+ * 跳转指定的历史记录位置
687
+ *
688
+ * 如果未向该函数传参或delta相等于 0,则该函数与调用location.reload()具有相同的效果。
689
+ *
690
+ * @param {number} delta - 跳转的步数(正数为前进,负数为后退)
691
+ */
692
+ abstract go(delta?: number): void;
693
+ /**
694
+ * 后退到上一个历史记录
695
+ */
696
+ back(): void;
697
+ /**
698
+ * 前进到下一个历史记录
699
+ */
700
+ forward(): void;
701
+ /**
702
+ * 替换当前页面
703
+ *
704
+ * @param {RouteTarget} target - 目标
705
+ * @return {boolean} - 是否跳转成功,非内存模式始终返回true
706
+ */
707
+ replace(target: RouteTarget | RouteIndex): Promise<NavigateResult>;
708
+ /**
709
+ * 跳转到新的页面
710
+ *
711
+ * @param {RouteTarget} target - 目标
712
+ * @return {boolean} - 是否跳转成功,非内存模式始终返回true
713
+ */
714
+ push(target: RouteTarget | RouteIndex): Promise<NavigateResult>;
715
+ /**
716
+ * 初始化路由器
717
+ *
718
+ * 只能初始化一次,多次初始化无效。
719
+ *
720
+ * 如果你使用的`createRouter(options)`助手函数创建的路由器实例则无需调用该方法。
721
+ *
722
+ * @return {this} - 返回当前路由器实例
723
+ */
724
+ initialize(): this;
725
+ /**
726
+ * 此方法用于浏览器端滚动到指定位置
727
+ *
728
+ * @param scrollTarget
729
+ */
730
+ scrollTo(scrollTarget: ScrollTarget | undefined): void;
731
+ /**
732
+ * 创建路由位置对象
733
+ * 根据导航目标创建标准化的路由位置信息
734
+ *
735
+ * @param {RouteTarget} target - 导航目标
736
+ * @return {RouteLocation} 路由位置对象
737
+ */
738
+ createRouteLocation(target: RouteTarget): RouteLocation;
739
+ /**
740
+ * 路由导航方法
741
+ *
742
+ * 处理所有的路由跳转请求,包括 push 和 replace
743
+ *
744
+ * @param {RouteTarget} target - 导航目标
745
+ * @return {Promise<NavigateResult>} 导航结果
746
+ */
747
+ navigate(target: RouteTarget): Promise<NavigateResult>;
748
+ /**
749
+ * 更新当前导航数据中的query参数
750
+ *
751
+ * 会同步更新`fullPath`
752
+ *
753
+ * @param {Record<string, string>} query - 新的query参数对象
754
+ * @public
755
+ */
756
+ updateQuery(query: Record<string, string>): void;
757
+ /**
758
+ * 更新当前导航数据中的hash参数
759
+ *
760
+ * 会同步更新`fullPath`
761
+ *
762
+ * @param {`#${string}` | ''} hash - 新的hash参数,如果为空则表示无hash
763
+ * @protected
764
+ */
765
+ updateHash(hash: `#${string}` | ''): void;
766
+ /**
767
+ * 创建路由元素
768
+ *
769
+ * @param route
770
+ * @param name
771
+ * @protected
772
+ */
773
+ protected createRouteViewElement(route: ReadonlyRouteNormalized, name: string): VNode<WidgetType> | undefined;
774
+ /* Excluded from this release type: _completeViewRender */
775
+ /**
776
+ * 完成导航过程
777
+ * 更新路由状态并触发相关的生命周期钩子
778
+ *
779
+ * @param {_ScrollToOptions} savedPosition - 保存的滚动位置
780
+ * @protected
781
+ */
782
+ protected completeNavigation(savedPosition?: _ScrollToOptions): void;
783
+ /**
784
+ * 初始化路由器
785
+ *
786
+ * 子类可重写此方法以完成路由器的初始化
787
+ *
788
+ * @private
789
+ */
790
+ protected abstract initializeRouter(): void;
791
+ /**
792
+ * 创建完整路径
793
+ *
794
+ * @protected
795
+ * @param path - 路径
796
+ * @param query - ?查询参数
797
+ * @param hash - #哈希值
798
+ * @param suffix - 路径后缀
799
+ * @return {string}
800
+ */
801
+ protected makeFullPath(path: string, query: `?${string}` | '' | Record<string, string>, hash: HashStr, suffix: string): `/${string}`;
802
+ /**
803
+ * 添加历史记录
804
+ *
805
+ * 子类必须实现该方法,且需要调用`this.completeNavigation(routeLocation)`方法标记完成导航!
806
+ *
807
+ * @param {RouteLocation} routeLocation - 新的路由位置对象
808
+ * @protected
809
+ */
810
+ protected abstract pushHistory(routeLocation: RouteLocation): void;
811
+ /**
812
+ * 替换历史记录
813
+ *
814
+ * 子类必须实现该方法,且需要调用`this.completeNavigation(routeLocation)`方法标记完成导航!
815
+ *
816
+ * @param {RouteLocation} routeLocation - 新的路由位置对象
817
+ * @protected
818
+ */
819
+ protected abstract replaceHistory(routeLocation: RouteLocation): void;
820
+ /**
821
+ * 触发路由前置守卫
822
+ *
823
+ * @param {RouteLocation} to - 路由目标对象
824
+ * @param {RouteLocation} from - 前路由对象
825
+ * @return {false | RouteTarget} - 返回false表示阻止导航,返回新的路由目标对象则表示导航到新的目标
826
+ */
827
+ protected onBeforeEach(to: RouteLocation, from: RouteLocation): BeforeEachCallbackResult;
828
+ /**
829
+ * 触发路由后置守卫
830
+ *
831
+ * @param {ReadonlyRouteLocation} to - 路由目标对象
832
+ * @param {ReadonlyRouteLocation} from - 前路由对象
833
+ */
834
+ protected onAfterEach(to: ReadonlyRouteLocation, from: ReadonlyRouteLocation): void;
835
+ /**
836
+ * 更新路由数据
837
+ * 使用补丁更新的方式更新路由状态
838
+ *
839
+ * @param {RouteLocation} newLocation - 新的路由数据
840
+ * @private
841
+ */
842
+ private updateRouteLocation;
843
+ /**
844
+ * 处理滚动行为
845
+ * 根据配置和保存的位置信息处理页面滚动
846
+ *
847
+ * @param {ReadonlyRouteLocation} to - 目标路由
848
+ * @param {ReadonlyRouteLocation} from - 当前路由
849
+ * @param {_ScrollToOptions} savedPosition - 保存的滚动位置
850
+ * @private
851
+ */
852
+ protected onScrollBehavior(to: ReadonlyRouteLocation, from: ReadonlyRouteLocation, savedPosition: _ScrollToOptions | undefined): Promise<void>;
853
+ /**
854
+ * @inheritDoc
855
+ */
856
+ removeRoute(index: RouteIndex): RouteNormalized | undefined;
857
+ }
858
+
859
+ /**
860
+ * # 路由跳转小部件
861
+ *
862
+ * 它只是简单的实现了一个a标签,点击后跳转到目标路由,
863
+ * 如果有更高级的定制需求,往往你可以项目中自行编写一个小部件来实现任何你想要的效果。
864
+ */
865
+ export declare class RouterLink extends Widget<RouterLinkProps> {
866
+ /**
867
+ * 路由目标
868
+ *
869
+ * 计算属性
870
+ *
871
+ * @protected
872
+ */
873
+ protected target: Computed<RouteTarget | HttpUrl | undefined>;
874
+ /**
875
+ * 路由目标对应的`RouteLocation`对象
876
+ *
877
+ * 计算属性
878
+ *
879
+ * @protected
880
+ */
881
+ protected location: Computed<RouteLocation | undefined>;
882
+ /**
883
+ * 激活状态
884
+ *
885
+ * 计算属性
886
+ *
887
+ * @protected
888
+ */
889
+ protected active: Computed<boolean> | undefined;
890
+ protected htmlProps: Computed<HTMLProperties<HTMLAnchorElement>>;
891
+ private static isHttpOrHttpsUrl;
892
+ constructor(props: RouterLinkProps);
893
+ /**
894
+ * 当前是否处于激活状态
895
+ */
896
+ get isActive(): boolean | undefined;
897
+ get isDisabled(): boolean;
898
+ /**
899
+ * 路由目标地址
900
+ */
901
+ get href(): string;
902
+ /**
903
+ * 导航到目标路由
904
+ *
905
+ * 该方法用于处理`a`标签的点击事件
906
+ *
907
+ * @param e
908
+ */
909
+ protected navigate(e: MouseEvent): void;
910
+ protected build(): Element_2;
911
+ }
912
+
913
+ export declare interface RouterLinkProps {
914
+ /**
915
+ * 要跳转的目标
916
+ *
917
+ * 可以是路由目标对象,也可以是路由索引
918
+ */
919
+ to: RouteTarget | RouteIndex;
920
+ /**
921
+ * 子节点插槽
922
+ */
923
+ children?: Element_2 | Element_2[] | string;
924
+ /**
925
+ * a 标签的style属性
926
+ */
927
+ style?: HTMLStyleProperties;
928
+ /**
929
+ * a 标签的class属性
930
+ */
931
+ class?: HTMLClassProperties;
932
+ /**
933
+ * a 标签的target属性
934
+ *
935
+ * 仅http或https外部连接支持此属性
936
+ */
937
+ target?: '_blank' | '_self' | '_parent' | '_top';
938
+ /**
939
+ * 是否禁用
940
+ *
941
+ * @default false
942
+ */
943
+ disabled?: boolean;
944
+ /**
945
+ * 激活状态计算
946
+ *
947
+ * 如果启用了激活状态计算,那么当路由匹配到当前路由时,a标签会添加`aria-current="page"`属性,
948
+ *
949
+ * 算法:
950
+ * - 如果路由索引以/开头,严格匹配`Router.instance.currentRouteLocation.path === to.index`,模糊匹配`Router.instance.currentRouteLocation.fullPath.startsWith(to.index)`
951
+ * - 如果路由索引不以/开头,则会匹配`Router.instance.currentRouteLocation.matched[i].name`,仅支持严格匹配
952
+ *
953
+ * 可选值:
954
+ * - none:不计算激活状态
955
+ * - obscure:模糊匹配,只要目标路由的路径以当前路由的路径开头,就认为当前路由处于激活状态
956
+ * - strict:严格匹配,只有目标路由的路径完全匹配当前路由的路径,才认为当前路由处于激活状态
957
+ *
958
+ * @default 'none'
959
+ */
960
+ active?: 'none' | 'obscure' | 'strict';
961
+ /**
962
+ * 导航回调函数
963
+ *
964
+ * @param {NavigateResult} result - 导航结果
965
+ */
966
+ callback?: (result: NavigateResult) => void;
967
+ /**
968
+ * 是否可拖拽
969
+ *
970
+ * @default false
971
+ */
972
+ draggable?: boolean;
973
+ }
974
+
975
+ /**
976
+ * 定义路由器配置选项接口
977
+ *
978
+ * 允许用户自定义路由的行为和属性
979
+ *
980
+ * @template T - 历史模式类型,支持:'hash' | 'path' | 'memory'
981
+ */
982
+ export declare interface RouterOptions<T extends HistoryMode = HistoryMode> {
983
+ /**
984
+ * 指定路由的基础路径
985
+ *
986
+ * 通常用于在部署时指定子目录
987
+ */
988
+ base?: `/${string}`;
989
+ /**
990
+ * 指定路由的历史模式,可以是 'path' | 'hash' | 'memory'
991
+ *
992
+ * @default 'hash'
993
+ */
994
+ mode?: T;
995
+ /**
996
+ * 是否启用严格模式
997
+ *
998
+ * 在严格模式下,会区分大小写
999
+ *
1000
+ * @default false
1001
+ */
1002
+ strict?: boolean;
1003
+ /**
1004
+ * 定义路由规则的数组
1005
+ *
1006
+ * 每个路由规则描述了路径和对应的组件或其他信息
1007
+ *
1008
+ * @example
1009
+ * ```ts
1010
+ * const routes: Route[] = [
1011
+ * { path: '/', widget: Home },
1012
+ * { path: '/about', widget: About },
1013
+ * { path: '/user/:id', widget: User },
1014
+ * ]
1015
+ * ```
1016
+ */
1017
+ routes: Route[];
1018
+ /**
1019
+ * 指定路由的后缀
1020
+ *
1021
+ * 可选值:
1022
+ * - '*':表示匹配任何后缀
1023
+ * - 字符串:表示匹配指定后缀
1024
+ * - 字符串数组:表示匹配多个后缀
1025
+ * - false:表示完全匹配路径路由path
1026
+ *
1027
+ * @default '*'
1028
+ */
1029
+ suffix?: '*' | string | string[] | false;
1030
+ /**
1031
+ * 默认的后缀
1032
+ *
1033
+ * 如需使url地址看起来更符合静态网站特征,可以指定一个默认的后缀,例如'.html'。
1034
+ *
1035
+ * @default ''
1036
+ */
1037
+ defaultSuffix?: string;
1038
+ /**
1039
+ * 默认的动态路由匹配模式
1040
+ *
1041
+ * 允许用户定义复杂的路径匹配规则
1042
+ *
1043
+ * @default /[\w.]+/
1044
+ */
1045
+ pattern?: RegExp;
1046
+ /**
1047
+ * 定义滚动行为
1048
+ *
1049
+ * 可以是一个函数或行为标识符,决定了当路由变化时如何滚动页面
1050
+ *
1051
+ * @default 'smooth'
1052
+ */
1053
+ scrollBehavior?: _ScrollBehavior | ScrollBehaviorHandler;
1054
+ /**
1055
+ * 在每个路由进入之前调用的钩子函数
1056
+ * 允许用户在路由激活之前执行逻辑检查或重定向
1057
+ */
1058
+ beforeEach?: BeforeEnterCallback;
1059
+ /**
1060
+ * 在每个路由进入之后调用的钩子函数
1061
+ * 允许用户在路由激活之后执行逻辑,例如页面初始化
1062
+ */
1063
+ afterEach?: AfterEnterCallback;
1064
+ /**
1065
+ * 未匹配到路由时要渲染的组件(仅在根`RouterView`渲染)
1066
+ *
1067
+ * 如果你需要在未匹配到路由时重定向到指定的页面,你不应该使用`missing`选项,
1068
+ * 而是应该在路由`beforeEach`钩子中判断`to.matched.length === 0`时返回重定向目标。
1069
+ *
1070
+ * > 注意:如果你设置了`missing`选项,新路由没有匹配时也会更新`URL`地址,然后渲染`missing`组件,
1071
+ * 你可以通过`useRoute().matched.length`来判断是否真正匹配到了路由。
1072
+ */
1073
+ missing?: RouteWidget;
1074
+ }
1075
+
1076
+ /**
1077
+ * 路由注册基类
1078
+ */
1079
+ declare abstract class RouterRegistry {
1080
+ protected readonly _options: Readonly<InitializedRouterOptions>;
1081
+ protected readonly _namedRoutes: Map<string, RouteNormalized>;
1082
+ protected readonly _dynamicRoutes: Map<number, DynamicRouteRecord[]>;
1083
+ protected readonly _pathRoutes: Map<string, RouteNormalized>;
1084
+ protected readonly _parentRoute: WeakMap<RouteNormalized, RouteNormalized>;
1085
+ protected constructor(options: RouterOptions);
1086
+ /**
1087
+ * 获取配置
1088
+ */
1089
+ get options(): Readonly<InitializedRouterOptions>;
1090
+ /**
1091
+ * 路由器模式
1092
+ */
1093
+ get mode(): HistoryMode;
1094
+ /**
1095
+ * 未匹配到路由时在根路由器视图中要渲染的组件
1096
+ */
1097
+ get missing(): RouteWidget | undefined;
1098
+ /**
1099
+ * 获取所有路由映射
1100
+ */
1101
+ get pathRoutes(): ReadonlyMap<string, RouteNormalized>;
1102
+ /**
1103
+ * 获取所有命名路由映射
1104
+ */
1105
+ get namedRoutes(): ReadonlyMap<string, RouteNormalized>;
1106
+ /**
1107
+ * 动态路由记录
1108
+ */
1109
+ get dynamicRoutes(): Map<number, DynamicRouteRecord[]>;
1110
+ /**
1111
+ * 获取已规范的路由表
1112
+ */
1113
+ get routes(): ReadonlyArray<RouteNormalized>;
1114
+ /**
1115
+ * 基本路径
1116
+ */
1117
+ get basePath(): `/${string}`;
1118
+ /**
1119
+ * 受支持的`path`后缀名
1120
+ */
1121
+ get suffix(): RouterOptions['suffix'];
1122
+ /**
1123
+ * 删除路由
1124
+ *
1125
+ * @param {string} index path或name
1126
+ * @returns {RouteNormalized|undefined} - 删除成功返回被删除的路由对象,否则返回undefined
1127
+ */
1128
+ removeRoute(index: RouteIndex): RouteNormalized | undefined;
1129
+ /**
1130
+ * 添加路由
1131
+ *
1132
+ * @param {Object} route 路由对象
1133
+ * @param {string} [parent] 父路由索引,可以是path|name
1134
+ * @returns {void}
1135
+ */
1136
+ addRoute(route: Route, parent?: string): void;
1137
+ /**
1138
+ * 根据索引或路由目标查找路由
1139
+ *
1140
+ * @param {string|Object} target 路由索引或目标对象
1141
+ * @returns {RouteNormalized|undefined} 匹配的路由对象,如果未找到则返回undefined
1142
+ */
1143
+ findRoute(target: RouteIndex | RouteTarget): RouteNormalized | undefined;
1144
+ /**
1145
+ * 根据path查找路由
1146
+ *
1147
+ * @param {string} path - 路由路径
1148
+ * @returns {RouteNormalized|undefined} - 路由对象,如果未找到则返回undefined
1149
+ */
1150
+ findPathRoute(path: RoutePath): RouteNormalized | undefined;
1151
+ /**
1152
+ * 查找命名路由
1153
+ *
1154
+ * @param {string} name
1155
+ * @returns {RouteNormalized|undefined} - 路由对象,如果未找到则返回undefined
1156
+ */
1157
+ findNamedRoute(name: RouteName): RouteNormalized | undefined;
1158
+ /**
1159
+ * 获取路由的父路由
1160
+ */
1161
+ findParentRoute(route: RouteNormalized): RouteNormalized | undefined;
1162
+ /**
1163
+ * 根据给定的路径匹配相应的路由
1164
+ *
1165
+ * 此方法首先格式化输入路径,然后根据路径匹配静态路由和动态路由
1166
+ * 对于静态路由,直接比较路径是否相等;对于动态路由,使用正则表达式进行匹配
1167
+ * 匹配成功后,验证路径的后缀是否符合要求,如果符合则返回匹配结果,包括路由和参数(如果有)
1168
+ *
1169
+ * @param path 要匹配的路径
1170
+ * @returns {object|undefined} 如果找到匹配的路由,则返回匹配结果对象;否则返回undefined
1171
+ */
1172
+ matchRoute(path: RoutePath): MatchResult | undefined;
1173
+ /**
1174
+ * 初始化路由表
1175
+ */
1176
+ protected setupRoutes(routes: Route[]): void;
1177
+ /**
1178
+ * 从源路由表中删除路由
1179
+ */
1180
+ private removedFromRoutes;
1181
+ /**
1182
+ * 删除动态路由映射
1183
+ */
1184
+ private removeDynamicRoute;
1185
+ /**
1186
+ * 注册路由
1187
+ *
1188
+ * @param route 要注册的路由对象
1189
+ * @param group 父路由对象
1190
+ * @returns {RouteNormalized} 规范化的路由对象
1191
+ */
1192
+ private registerRoute;
1193
+ /**
1194
+ * 如果路径是严格匹配,则转换为小写
1195
+ */
1196
+ private strictPath;
1197
+ /**
1198
+ * 记录路由
1199
+ */
1200
+ private recordRoute;
1201
+ /**
1202
+ * 添加动态路由
1203
+ */
1204
+ private recordDynamicRoute;
1205
+ }
1206
+
1207
+ /**
1208
+ * # 路由器视图
1209
+ *
1210
+ * 用于渲染路由线路配置的`widget`,可以在子组件中嵌套`RouterView`,但应用内只能存在一个根视图。
1211
+ *
1212
+ * 如需实现页面缓存等功能,可以重写该类的{@link build}方法。
1213
+ */
1214
+ export declare class RouterView extends Widget<RouteOptions> {
1215
+ private readonly _$index;
1216
+ private _$currentRoute?;
1217
+ private _$currentElement;
1218
+ constructor(props: RouteOptions);
1219
+ /**
1220
+ * 当前路由器视图所在层级索引
1221
+ *
1222
+ * `index`的值从0开始,它与`RouteLocation.matched`数组下标一一对应
1223
+ */
1224
+ get index(): number;
1225
+ /**
1226
+ * 是否为最后一个路由视图
1227
+ */
1228
+ get isLastView(): boolean;
1229
+ /**
1230
+ * 视图名称
1231
+ *
1232
+ * @default 'default'
1233
+ */
1234
+ get name(): string;
1235
+ /**
1236
+ * 获取当前匹配的路线配置
1237
+ *
1238
+ * 注意未匹配时会返回`undefined`,匹配成功时返回的是`ReadonlyRouteNormalized`
1239
+ */
1240
+ get matchedRoute(): ReadonlyRouteNormalized | undefined;
1241
+ /**
1242
+ * 当前路由器视图要显示的虚拟节点
1243
+ *
1244
+ * 注意未匹配时会返回`undefined`,匹配成功时返回的是`VNode<WidgetType>`
1245
+ *
1246
+ * @protected
1247
+ */
1248
+ protected get currentElement(): VNode<WidgetType> | undefined;
1249
+ /**
1250
+ * 当前路由器视图要显示的组件
1251
+ *
1252
+ * @protected
1253
+ */
1254
+ protected get currentWidget(): WidgetType | undefined;
1255
+ /**
1256
+ * 当前的路由位置对象
1257
+ *
1258
+ * @protected
1259
+ */
1260
+ protected get location(): DeepReadonly<RouteLocation_2>;
1261
+ /**
1262
+ * @inheritDoc
1263
+ */
1264
+ protected onMounted(): void;
1265
+ /**
1266
+ * @inheritDoc
1267
+ */
1268
+ protected onUpdated(): void;
1269
+ /**
1270
+ * ## 构建视图
1271
+ *
1272
+ * 可以重写该方法实现自定义的视图构建逻辑。
1273
+ *
1274
+ * 例如,使用`KeepAlive`小部件进行页面缓存:
1275
+ * ```tsx
1276
+ * protected build() {
1277
+ * // 使用空片段节点占位
1278
+ * if (!this.currentElement) return <></> // 不可省略,因为`KeepAlive`不能渲染非组件节点。
1279
+ *
1280
+ * // 将当前要进行展示的小部件构造函数传递给`KeepAlive`插槽,会在切换页面时缓存当前页面状态。
1281
+ * return <KeepAlive>{this.currentElement}</KeepAlive>
1282
+ * }
1283
+ * ```
1284
+ * @protected
1285
+ */
1286
+ protected build(): Element_2;
1287
+ /**
1288
+ * 视图渲染完成通知路由器
1289
+ *
1290
+ * @private
1291
+ */
1292
+ private completeViewRender;
1293
+ }
1294
+
1295
+ /**
1296
+ * 路由目标
1297
+ *
1298
+ * 用于描述导航的目标位置
1299
+ */
1300
+ export declare interface RouteTarget {
1301
+ /**
1302
+ * 路由索引,/开头为路径,否则为名称
1303
+ */
1304
+ index: RouteIndex;
1305
+ /**
1306
+ * URL hash
1307
+ */
1308
+ hash?: HashStr;
1309
+ /**
1310
+ * URL 查询参数
1311
+ */
1312
+ query?: Record<string, string>;
1313
+ /**
1314
+ * 路由参数
1315
+ */
1316
+ params?: Record<string, any>;
1317
+ /**
1318
+ * 是否替换当前路由
1319
+ */
1320
+ isReplace?: boolean;
1321
+ }
1322
+
1323
+ /**
1324
+ * 路由视图小部件
1325
+ *
1326
+ * 可以是普通组件或懒加载组件
1327
+ */
1328
+ export declare type RouteWidget = WidgetType | LazyLoad<WidgetType>;
1329
+
1330
+ /**
1331
+ * 滚动行为
1332
+ */
1333
+ export declare type _ScrollBehavior = 'auto' | 'instant' | 'smooth';
1334
+
1335
+ /**
1336
+ * 滚动行为处理器
1337
+ */
1338
+ export declare type ScrollBehaviorHandler = (to: ReadonlyRouteLocation, from: ReadonlyRouteLocation, savedPosition: _ScrollToOptions | undefined) => ScrollResult | Promise<ScrollResult>;
1339
+
1340
+ /**
1341
+ * 滚动到视图配置
1342
+ */
1343
+ export declare interface _ScrollIntoViewOptions extends ScrollIntoViewOptions {
1344
+ el: Element | `#${string}` | string;
1345
+ }
1346
+
1347
+ /**
1348
+ * 滚动结果
1349
+ */
1350
+ export declare type ScrollResult = ScrollTarget | false;
1351
+
1352
+ /**
1353
+ * 滚动目标
1354
+ */
1355
+ export declare type ScrollTarget = _ScrollToOptions | _ScrollIntoViewOptions;
1356
+
1357
+ /**
1358
+ * 滚动配置
1359
+ */
1360
+ export declare interface _ScrollToOptions {
1361
+ left?: number;
1362
+ top?: number;
1363
+ behavior?: _ScrollBehavior;
1364
+ }
1365
+
1366
+ /**
1367
+ * 获取当前`RouteLocation`对象
1368
+ *
1369
+ * 它是`Router.instance.currentRouteLocation`属性的助手函数,优化函数式编程体验。
1370
+ *
1371
+ * 简单示例:
1372
+ * ```jsx
1373
+ * import { useRoute,watch } from 'vitarx-router'
1374
+ *
1375
+ * // 监听路由参数变化示例
1376
+ * export default function App() {
1377
+ * const route = useRoute()
1378
+ * watch(()=>route.params.id, (newId, oldId) => {
1379
+ * console.log(`监听到id参数变化, 旧值:${oldId}, 新值:${newId}`)
1380
+ * })
1381
+ * return <div>当前路由参数ID:{route.params.id}</div>
1382
+ * }
1383
+ * ```
1384
+ *
1385
+ * @return {ReadonlyRouteLocation} - 只读的`RouteLocation`对象
1386
+ */
1387
+ export declare function useRoute(): ReadonlyRouteLocation;
1388
+
1389
+ /**
1390
+ * 获取路由器实例
1391
+ *
1392
+ * 与使用`Router.instance`静态属性获取是一致的效果。
1393
+ *
1394
+ * @return {RouterCore} - 路由器实例
1395
+ * @throws {Error} - 如果路由器实例未初始化,则抛出异常
1396
+ */
1397
+ export declare function useRouter<T extends Router>(): T;
1398
+
1
1399
  export { }