• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { Callback } from './@ohos.base';
17import { AsyncCallback } from './@ohos.base';
18
19/**
20 * @namespace router
21 * @syscap SystemCapability.ArkUI.ArkUI.Full
22 * @since 8
23 */
24/**
25 * @namespace router
26 * @syscap SystemCapability.ArkUI.ArkUI.Full
27 * @crossplatform
28 * @since 10
29 */
30declare namespace router {
31  /**
32   * Router Mode
33   *
34   * @enum { number }
35   * @syscap SystemCapability.ArkUI.ArkUI.Full
36   * @since 9
37   */
38  /**
39   * Router Mode
40   *
41   * @enum { number }
42   * @syscap SystemCapability.ArkUI.ArkUI.Full
43   * @crossplatform
44   * @since 10
45   */
46  export enum RouterMode {
47    /**
48     * Default route mode.
49     * The page will be added to the top of the page stack.
50     *
51     * @syscap SystemCapability.ArkUI.ArkUI.Full
52     * @since 9
53     */
54    /**
55     * Default route mode.
56     * The page will be added to the top of the page stack.
57     *
58     * @syscap SystemCapability.ArkUI.ArkUI.Full
59     * @crossplatform
60     * @since 10
61     */
62    Standard,
63
64    /**
65     * Single route mode.
66     * If the target page already has the same url page in the page stack,
67     * the same url page closest to the top of the stack will be moved to the top of the stack.
68     * If the target page url does not exist in the page stack, route will use default route mode.
69     *
70     * @syscap SystemCapability.ArkUI.ArkUI.Full
71     * @since 9
72     */
73    /**
74     * Single route mode.
75     * If the target page already has the same url page in the page stack,
76     * the same url page closest to the top of the stack will be moved to the top of the stack.
77     * If the target page url does not exist in the page stack, route will use default route mode.
78     *
79     * @syscap SystemCapability.ArkUI.ArkUI.Full
80     * @crossplatform
81     * @since 10
82     */
83    Single,
84  }
85
86  /**
87   * @typedef RouterOptions
88   * @syscap SystemCapability.ArkUI.ArkUI.Lite
89   * @since 8
90   */
91  interface RouterOptions {
92    /**
93     * URI of the destination page, which supports the following formats:
94     * 1. Absolute path of the page, which is provided by the pages list in the config.json file.
95     *    Example:
96     *      pages/index/index
97     *      pages/detail/detail
98     * 2. Particular path. If the URI is a slash (/), the home page is displayed.
99     *
100     * @type { string }
101     * @syscap SystemCapability.ArkUI.ArkUI.Lite
102     * @since 8
103     */
104    url: string;
105
106    /**
107     * Data that needs to be passed to the destination page during navigation.
108     * After the destination page is displayed, the parameter can be directly used for the page.
109     * For example, this.data1 (data1 is the key value of the params used for page navigation.)
110     *
111     * @type { ?Object }
112     * @syscap SystemCapability.ArkUI.ArkUI.Lite
113     * @since 8
114     */
115    params?: Object;
116  }
117
118  /**
119   * @typedef RouterState
120   * @syscap SystemCapability.ArkUI.ArkUI.Full
121   * @since 8
122   */
123  /**
124   * @typedef RouterState
125   * @syscap SystemCapability.ArkUI.ArkUI.Full
126   * @crossplatform
127   * @since 10
128   */
129  interface RouterState {
130    /**
131     * Index of the current page in the stack.
132     * NOTE: The index starts from 1 from the bottom to the top of the stack.
133     *
134     * @type { number }
135     * @syscap SystemCapability.ArkUI.ArkUI.Full
136     * @since 8
137     */
138    /**
139     * Index of the current page in the stack.
140     * NOTE: The index starts from 1 from the bottom to the top of the stack.
141     *
142     * @type { number }
143     * @syscap SystemCapability.ArkUI.ArkUI.Full
144     * @crossplatform
145     * @since 10
146     */
147    index: number;
148
149    /**
150     * Name of the current page, that is, the file name.
151     *
152     * @type { string }
153     * @syscap SystemCapability.ArkUI.ArkUI.Full
154     * @since 8
155     */
156    /**
157     * Name of the current page, that is, the file name.
158     *
159     * @type { string }
160     * @syscap SystemCapability.ArkUI.ArkUI.Full
161     * @crossplatform
162     * @since 10
163     */
164    name: string;
165
166    /**
167     * Path of the current page.
168     *
169     * @type { string }
170     * @syscap SystemCapability.ArkUI.ArkUI.Full
171     * @since 8
172     */
173    /**
174     * Path of the current page.
175     *
176     * @type { string }
177     * @syscap SystemCapability.ArkUI.ArkUI.Full
178     * @crossplatform
179     * @since 10
180     */
181    path: string;
182  }
183
184  /**
185   * @typedef EnableAlertOptions
186   * @syscap SystemCapability.ArkUI.ArkUI.Full
187   * @since 8
188   */
189  /**
190   * @typedef EnableAlertOptions
191   * @syscap SystemCapability.ArkUI.ArkUI.Full
192   * @crossplatform
193   * @since 10
194   */
195  interface EnableAlertOptions {
196    /**
197     * dialog context.
198     *
199     * @type { string }
200     * @syscap SystemCapability.ArkUI.ArkUI.Full
201     * @since 8
202     */
203    /**
204     * dialog context.
205     *
206     * @type { string }
207     * @syscap SystemCapability.ArkUI.ArkUI.Full
208     * @crossplatform
209     * @since 10
210     */
211    message: string;
212  }
213
214  /**
215   * Navigates to a specified page in the application based on the page URL and parameters.
216   *
217   * @param { RouterOptions } options - Options.
218   * @syscap SystemCapability.ArkUI.ArkUI.Full
219   * @since 8
220   * @deprecated since 9
221   * @useinstead ohos.router.router#pushUrl
222   */
223  function push(options: RouterOptions): void;
224
225  /**
226   * Navigates to a specified page in the application based on the page URL and parameters.
227   *
228   * @param { RouterOptions } options - Options.
229   * @param { AsyncCallback<void> } callback - the callback of pushUrl.
230   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
231   * @throws { BusinessError } 100001 - if UI execution context not found.
232   * @throws { BusinessError } 100002 - if the uri is not exist.
233   * @throws { BusinessError } 100003 - if the pages are pushed too much.
234   * @syscap SystemCapability.ArkUI.ArkUI.Full
235   * @since 9
236   */
237  /**
238   * Navigates to a specified page in the application based on the page URL and parameters.
239   *
240   * @param { RouterOptions } options - Options.
241   * @param { AsyncCallback<void> } callback - the callback of pushUrl.
242   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
243   * @throws { BusinessError } 100001 - if UI execution context not found.
244   * @throws { BusinessError } 100002 - if the uri is not exist.
245   * @throws { BusinessError } 100003 - if the pages are pushed too much.
246   * @syscap SystemCapability.ArkUI.ArkUI.Full
247   * @crossplatform
248   * @since 10
249   */
250  function pushUrl(options: RouterOptions, callback: AsyncCallback<void>): void;
251
252  /**
253   * Navigates to a specified page in the application based on the page URL and parameters.
254   *
255   * @param { RouterOptions } options - Options.
256   * @returns { Promise<void> } the promise returned by the function.
257   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
258   * @throws { BusinessError } 100001 - if UI execution context not found.
259   * @throws { BusinessError } 100002 - if the uri is not exist.
260   * @throws { BusinessError } 100003 - if the pages are pushed too much.
261   * @syscap SystemCapability.ArkUI.ArkUI.Full
262   * @since 9
263   */
264  /**
265   * Navigates to a specified page in the application based on the page URL and parameters.
266   *
267   * @param { RouterOptions } options - Options.
268   * @returns { Promise<void> } the promise returned by the function.
269   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
270   * @throws { BusinessError } 100001 - if UI execution context not found.
271   * @throws { BusinessError } 100002 - if the uri is not exist.
272   * @throws { BusinessError } 100003 - if the pages are pushed too much.
273   * @syscap SystemCapability.ArkUI.ArkUI.Full
274   * @crossplatform
275   * @since 10
276   */
277  function pushUrl(options: RouterOptions): Promise<void>;
278
279  /**
280   * Navigates to a specified page in the application based on the page URL and parameters.
281   *
282   * @param { RouterOptions } options - Options.
283   * @param { RouterMode } mode - RouterMode.
284   * @param { AsyncCallback<void> } callback - the callback of pushUrl.
285   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
286   * @throws { BusinessError } 100001 - if UI execution context not found.
287   * @throws { BusinessError } 100002 - if the uri is not exist.
288   * @throws { BusinessError } 100003 - if the pages are pushed too much.
289   * @syscap SystemCapability.ArkUI.ArkUI.Full
290   * @since 9
291   */
292  /**
293   * Navigates to a specified page in the application based on the page URL and parameters.
294   *
295   * @param { RouterOptions } options - Options.
296   * @param { RouterMode } mode - RouterMode.
297   * @param { AsyncCallback<void> } callback - the callback of pushUrl.
298   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
299   * @throws { BusinessError } 100001 - if UI execution context not found.
300   * @throws { BusinessError } 100002 - if the uri is not exist.
301   * @throws { BusinessError } 100003 - if the pages are pushed too much.
302   * @syscap SystemCapability.ArkUI.ArkUI.Full
303   * @crossplatform
304   * @since 10
305   */
306  function pushUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void;
307
308  /**
309   * Navigates to a specified page in the application based on the page URL and parameters.
310   *
311   * @param { RouterOptions } options - Options.
312   * @param { RouterMode } mode - RouterMode.
313   * @returns { Promise<void> } the promise returned by the function.
314   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
315   * @throws { BusinessError } 100001 - if UI execution context not found.
316   * @throws { BusinessError } 100002 - if the uri is not exist.
317   * @throws { BusinessError } 100003 - if the pages are pushed too much.
318   * @syscap SystemCapability.ArkUI.ArkUI.Full
319   * @since 9
320   */
321  /**
322   * Navigates to a specified page in the application based on the page URL and parameters.
323   *
324   * @param { RouterOptions } options - Options.
325   * @param { RouterMode } mode - RouterMode.
326   * @returns { Promise<void> } the promise returned by the function.
327   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
328   * @throws { BusinessError } 100001 - if UI execution context not found.
329   * @throws { BusinessError } 100002 - if the uri is not exist.
330   * @throws { BusinessError } 100003 - if the pages are pushed too much.
331   * @syscap SystemCapability.ArkUI.ArkUI.Full
332   * @crossplatform
333   * @since 10
334   */
335  function pushUrl(options: RouterOptions, mode: RouterMode): Promise<void>;
336
337  /**
338   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
339   *
340   * @param { RouterOptions } options - Options.
341   * @syscap SystemCapability.ArkUI.ArkUI.Lite
342   * @since 8
343   * @deprecated since 9
344   * @useinstead ohos.router.router#replaceUrl
345   */
346  function replace(options: RouterOptions): void;
347
348  /**
349   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
350   *
351   * @param { RouterOptions } options - Options.
352   * @param { AsyncCallback<void> } callback - the callback of replaceUrl.
353   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
354   * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system.
355   * @throws { BusinessError } 200002 - if the uri is not exist.
356   * @syscap SystemCapability.ArkUI.ArkUI.Lite
357   * @since 9
358   */
359  function replaceUrl(options: RouterOptions, callback: AsyncCallback<void>): void;
360
361  /**
362   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
363   *
364   * @param { RouterOptions } options - Options.
365   * @returns { Promise<void> } the promise returned by the function.
366   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
367   * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system.
368   * @throws { BusinessError } 200002 - if the uri is not exist.
369   * @syscap SystemCapability.ArkUI.ArkUI.Lite
370   * @since 9
371   */
372  function replaceUrl(options: RouterOptions): Promise<void>;
373
374  /**
375   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
376   *
377   * @param { RouterOptions } options - Options.
378   * @param { RouterMode } mode - RouterMode.
379   * @param { AsyncCallback<void> } callback - the callback of replaceUrl.
380   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
381   * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system.
382   * @throws { BusinessError } 200002 - if the uri is not exist.
383   * @syscap SystemCapability.ArkUI.ArkUI.Lite
384   * @since 9
385   */
386  function replaceUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void;
387
388  /**
389   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
390   *
391   * @param { RouterOptions } options - Options.
392   * @param { RouterMode } mode - RouterMode.
393   * @returns { Promise<void> } the promise returned by the function.
394   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
395   * @throws { BusinessError } 100001 - if can not get the delegate, only throw in standard system.
396   * @throws { BusinessError } 200002 - if the uri is not exist.
397   * @syscap SystemCapability.ArkUI.ArkUI.Lite
398   * @since 9
399   */
400  function replaceUrl(options: RouterOptions, mode: RouterMode): Promise<void>;
401
402  /**
403   * Returns to the previous page or a specified page.
404   *
405   * @param { RouterOptions } options - Options.
406   * @syscap SystemCapability.ArkUI.ArkUI.Full
407   * @since 8
408   */
409  /**
410   * Returns to the previous page or a specified page.
411   *
412   * @param { RouterOptions } options - Options.
413   * @syscap SystemCapability.ArkUI.ArkUI.Full
414   * @crossplatform
415   * @since 10
416   */
417  function back(options?: RouterOptions): void;
418
419  /**
420   * Clears all historical pages and retains only the current page at the top of the stack.
421   *
422   * @syscap SystemCapability.ArkUI.ArkUI.Full
423   * @since 8
424   */
425  /**
426   * Clears all historical pages and retains only the current page at the top of the stack.
427   *
428   * @syscap SystemCapability.ArkUI.ArkUI.Full
429   * @crossplatform
430   * @since 10
431   */
432  function clear(): void;
433
434  /**
435   * Obtains the number of pages in the current stack.
436   *
437   * @returns { string } Number of pages in the stack. The maximum value is 32.
438   * @syscap SystemCapability.ArkUI.ArkUI.Full
439   * @since 8
440   */
441  /**
442   * Obtains the number of pages in the current stack.
443   *
444   * @returns { string } Number of pages in the stack. The maximum value is 32.
445   * @syscap SystemCapability.ArkUI.ArkUI.Full
446   * @crossplatform
447   * @since 10
448   */
449  function getLength(): string;
450
451  /**
452   * Obtains information about the current page state.
453   *
454   * @returns { RouterState } Page state.
455   * @syscap SystemCapability.ArkUI.ArkUI.Full
456   * @since 8
457   */
458  /**
459   * Obtains information about the current page state.
460   *
461   * @returns { RouterState } Page state.
462   * @syscap SystemCapability.ArkUI.ArkUI.Full
463   * @crossplatform
464   * @since 10
465   */
466  function getState(): RouterState;
467
468  /**
469   * Pop up dialog to ask whether to back
470   *
471   * @param { EnableAlertOptions } options - Options.
472   * @syscap SystemCapability.ArkUI.ArkUI.Full
473   * @since 8
474   * @deprecated since 9
475   * @useinstead ohos.router.router#showAlertBeforeBackPage
476   */
477  function enableAlertBeforeBackPage(options: EnableAlertOptions): void;
478
479  /**
480   * Pop up alert dialog to ask whether to back
481   *
482   * @param { EnableAlertOptions } options - Options.
483   * @throws { BusinessError } 401 - if the type of the parameter is not object or the type of the message is not string.
484   * @throws { BusinessError } 100001 - if UI execution context not found.
485   * @syscap SystemCapability.ArkUI.ArkUI.Full
486   * @since 9
487   */
488  /**
489   * Pop up alert dialog to ask whether to back
490   *
491   * @param { EnableAlertOptions } options - Options.
492   * @throws { BusinessError } 401 - if the type of the parameter is not object or the type of the message is not string.
493   * @throws { BusinessError } 100001 - if UI execution context not found.
494   * @syscap SystemCapability.ArkUI.ArkUI.Full
495   * @crossplatform
496   * @since 10
497   */
498  function showAlertBeforeBackPage(options: EnableAlertOptions): void;
499
500  /**
501   * Cancel enableAlertBeforeBackPage
502   *
503   * @syscap SystemCapability.ArkUI.ArkUI.Full
504   * @since 8
505   * @deprecated since 9
506   * @useinstead ohos.router.router#hideAlertBeforeBackPage
507   */
508  function disableAlertBeforeBackPage(): void;
509
510  /**
511   * Hide alert before back page
512   *
513   * @syscap SystemCapability.ArkUI.ArkUI.Full
514   * @since 9
515   */
516  /**
517   * Hide alert before back page
518   *
519   * @syscap SystemCapability.ArkUI.ArkUI.Full
520   * @crossplatform
521   * @since 10
522   */
523  function hideAlertBeforeBackPage(): void;
524
525  /**
526   * Obtains information about the current page params.
527   *
528   * @returns { Object } Page params.
529   * @syscap SystemCapability.ArkUI.ArkUI.Full
530   * @since 8
531   */
532  /**
533   * Obtains information about the current page params.
534   *
535   * @returns { Object } Page params.
536   * @syscap SystemCapability.ArkUI.ArkUI.Full
537   * @crossplatform
538   * @since 10
539   */
540  function getParams(): Object;
541
542  /**
543   * @typedef NamedRouterOptions
544   * @syscap SystemCapability.ArkUI.ArkUI.Full
545   * @crossplatform
546   * @since 10
547   */
548  interface NamedRouterOptions {
549    /**
550     * Name of the destination named route.
551     *
552     * @type { string }
553     * @syscap SystemCapability.ArkUI.ArkUI.Full
554     * @crossplatform
555     * @since 10
556     */
557    name: string;
558
559    /**
560     * Data that needs to be passed to the destination page during navigation.
561     *
562     * @type { ?Object }
563     * @syscap SystemCapability.ArkUI.ArkUI.Full
564     * @crossplatform
565     * @since 10
566     */
567    params?: Object;
568  }
569
570  /**
571   * Navigates to a specified page in the application based on the page URL and parameters.
572   *
573   * @param { NamedRouterOptions } options - Options.
574   * @param { AsyncCallback<void> } callback - the callback of pushNamedRoute.
575   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
576   * @throws { BusinessError } 100001 - if UI execution context not found.
577   * @throws { BusinessError } 100003 - if the pages are pushed too much.
578   * @throws { BusinessError } 100004 - if the named route is not exist.
579   * @syscap SystemCapability.ArkUI.ArkUI.Full
580   * @crossplatform
581   * @since 10
582   */
583  function pushNamedRoute(options: NamedRouterOptions, callback: AsyncCallback<void>): void;
584
585  /**
586   * Navigates to a specified page in the application based on the page URL and parameters.
587   *
588   * @param { NamedRouterOptions } options - Options.
589   * @returns { Promise<void> } the promise returned by the function.
590   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
591   * @throws { BusinessError } 100001 - if UI execution context not found.
592   * @throws { BusinessError } 100003 - if the pages are pushed too much.
593   * @throws { BusinessError } 100004 - if the named route is not exist.
594   * @syscap SystemCapability.ArkUI.ArkUI.Full
595   * @crossplatform
596   * @since 10
597   */
598  function pushNamedRoute(options: NamedRouterOptions): Promise<void>;
599
600  /**
601   * Navigates to a specified page in the application based on the page URL and parameters.
602   *
603   * @param { NamedRouterOptions } options - Options.
604   * @param { RouterMode } mode - RouterMode.
605   * @param { AsyncCallback<void> } callback - the callback of pushNamedRoute.
606   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
607   * @throws { BusinessError } 100001 - if UI execution context not found.
608   * @throws { BusinessError } 100003 - if the pages are pushed too much.
609   * @throws { BusinessError } 100004 - if the named route is not exist.
610   * @syscap SystemCapability.ArkUI.ArkUI.Full
611   * @crossplatform
612   * @since 10
613   */
614  function pushNamedRoute(options: NamedRouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void;
615
616  /**
617   * Navigates to a specified page in the application based on the page URL and parameters.
618   *
619   * @param { NamedRouterOptions } options - Options.
620   * @param { RouterMode } mode - RouterMode.
621   * @returns { Promise<void> } the promise returned by the function.
622   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
623   * @throws { BusinessError } 100001 - if UI execution context not found.
624   * @throws { BusinessError } 100003 - if the pages are pushed too much.
625   * @throws { BusinessError } 100004 - if the named route is not exist.
626   * @syscap SystemCapability.ArkUI.ArkUI.Full
627   * @crossplatform
628   * @since 10
629   */
630  function pushNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise<void>;
631
632  /**
633   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
634   *
635   * @param { NamedRouterOptions } options - Options.
636   * @param { AsyncCallback<void> } callback - the callback of replaceNamedRoute.
637   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
638   * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system.
639   * @throws { BusinessError } 100004 - if the named route is not exist.
640   * @syscap SystemCapability.ArkUI.ArkUI.Full
641   * @crossplatform
642   * @since 10
643   */
644  function replaceNamedRoute(options: NamedRouterOptions, callback: AsyncCallback<void>): void;
645
646  /**
647   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
648   *
649   * @param { NamedRouterOptions } options - Options.
650   * @returns { Promise<void> } the promise returned by the function.
651   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
652   * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system.
653   * @throws { BusinessError } 100004 - if the named route is not exist.
654   * @syscap SystemCapability.ArkUI.ArkUI.Full
655   * @crossplatform
656   * @since 10
657   */
658  function replaceNamedRoute(options: NamedRouterOptions): Promise<void>;
659
660  /**
661   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
662   *
663   * @param { NamedRouterOptions } options - Options.
664   * @param { RouterMode } mode - RouterMode.
665   * @param { AsyncCallback<void> } callback - the callback of replaceNamedRoute.
666   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
667   * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system.
668   * @throws { BusinessError } 100004 - if the named route is not exist.
669   * @syscap SystemCapability.ArkUI.ArkUI.Full
670   * @crossplatform
671   * @since 10
672   */
673  function replaceNamedRoute(options: NamedRouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void;
674
675  /**
676   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
677   *
678   * @param { NamedRouterOptions } options - Options.
679   * @param { RouterMode } mode - RouterMode.
680   * @returns { Promise<void> } the promise returned by the function.
681   * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string.
682   * @throws { BusinessError } 100001 - if can not get the delegate, only throw in standard system.
683   * @throws { BusinessError } 100004 - if the named route is not exist.
684   * @syscap SystemCapability.ArkUI.ArkUI.Full
685   * @crossplatform
686   * @since 10
687   */
688  function replaceNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise<void>;
689}
690
691export default router;
692