Skip to content

Commit 34fb9f9

Browse files
committed
docs: add onError()
1 parent c76feab commit 34fb9f9

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

docs/api/index.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,9 @@ hasRoute(name: string | symbol): boolean
573573

574574
_Parameters_
575575

576-
| Parameter | Type | Description |
577-
| --------- | ------------------------------------------------- | -------------------------- |
578-
| name | `string \| symbol` | Name of the route to check |
576+
| Parameter | Type | Description |
577+
| --------- | ------------------ | -------------------------- |
578+
| name | `string \| symbol` | Name of the route to check |
579579

580580
### isReady
581581

@@ -594,14 +594,14 @@ Adds an error handler that is called every time a non caught error happens durin
594594
**Signature:**
595595

596596
```typescript
597-
onError(handler: (error: any) => any): () => void
597+
onError(handler: (error: any, to: RouteLocationNormalized, from: RouteLocationNormalized) => any): () => void
598598
```
599599

600600
_Parameters_
601601

602-
| Parameter | Type | Description |
603-
| --------- | --------------------- | ------------------------- |
604-
| handler | `(error: any) => any` | error handler to register |
602+
| Parameter | Type | Description |
603+
| --------- | --------------------------------------------------------------------------------- | ------------------------- |
604+
| handler | `(error: any, to: RouteLocationNormalized, from: RouteLocationNormalized) => any` | error handler to register |
605605

606606
### push
607607

@@ -631,9 +631,9 @@ removeRoute(name: string | symbol): void
631631

632632
_Parameters_
633633

634-
| Parameter | Type | Description |
635-
| --------- | --------------------------------------------- | --------------------------- |
636-
| name | `string \| symbol` | Name of the route to remove |
634+
| Parameter | Type | Description |
635+
| --------- | ------------------ | --------------------------- |
636+
| name | `string \| symbol` | Name of the route to remove |
637637

638638
### replace
639639

docs/zh/api/index.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ export declare function createWebHistory(base?: string): RouterHistory
216216

217217
### 参数
218218

219-
| 参数 | 类型 | 描述 |
220-
| ---- | -------- | -------------------------------------------------------------------------------------------------- |
219+
| 参数 | 类型 | 描述 |
220+
| ---- | -------- | ------------------------------------------------------------------------------------------------ |
221221
| base | `string` | 提供的可选 base。当应用程序被托管在诸如 `https://example.com/folder/` 之类的文件夹中时非常有用。 |
222222

223223
### 示例
@@ -239,8 +239,8 @@ export declare function createWebHashHistory(base?: string): RouterHistory
239239

240240
### 参数
241241

242-
| 参数 | 类型 | 描述 |
243-
| ---- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
242+
| 参数 | 类型 | 描述 |
243+
| ---- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
244244
| base | `string` | 提供可选的 base。默认是 `location.pathname + location.search`。如果 `head` 中有一个 `<base>`,它的值将被忽略,而采用这个参数。**但请注意它会影响所有的 history.pushState() 调用**,这意味着如果你使用一个 `<base>` 标签,它的 `href`**必须与这个参数相匹配** (请忽略 `#` 后面的所有内容) |
245245

246246
### 示例
@@ -366,8 +366,8 @@ export declare function useLink(props: RouterLinkOptions): {
366366

367367
#### 参数
368368

369-
| 参数 | 类型 | 描述 |
370-
| ----- | ----------------- | ---------------------------------------------------------------- |
369+
| 参数 | 类型 | 描述 |
370+
| ----- | ------------------- | ---------------------------------------------------------------- |
371371
| props | `RouterLinkOptions` | props 对象可以传递给`<router-link>`。接收 `Ref``ComputedRef` |
372372

373373
### useRoute
@@ -424,10 +424,10 @@ addRoute(parentName: string | symbol, route: RouteRecordRaw): () => void
424424

425425
_参数_
426426

427-
| 参数 | 类型 | 描述 |
428-
| ---------- | ----------------------------------- | ---------------- |
427+
| 参数 | 类型 | 描述 |
428+
| ---------- | ----------------------------------- | -------------------------------------- |
429429
| parentName | `string \| symbol` | 父路由记录,`route` 应该被添加到的位置 |
430-
| route | [`RouteRecordRaw`](#routerecordraw) | 要添加的路由记录 |
430+
| route | [`RouteRecordRaw`](#routerecordraw) | 要添加的路由记录 |
431431

432432
### addRoute
433433

@@ -461,8 +461,8 @@ afterEach(guard: NavigationHookAfter): () => void
461461

462462
_参数_
463463

464-
| 参数 | 类型 | 描述 |
465-
| ----- | ------------------- | ---------------- |
464+
| 参数 | 类型 | 描述 |
465+
| ----- | --------------------- | ---------------- |
466466
| guard | `NavigationHookAfter` | 要添加的导航钩子 |
467467

468468
#### 示例
@@ -573,8 +573,8 @@ hasRoute(name: string | symbol): boolean
573573

574574
_参数_
575575

576-
| 参数 | 类型 | 描述 |
577-
| ---- | ------- | ------- |
576+
| 参数 | 类型 | 描述 |
577+
| ---- | ------------------ | ---------------- |
578578
| name | `string \| symbol` | 要确认的路由名称 |
579579

580580
### isReady
@@ -594,14 +594,14 @@ isReady(): Promise<void>
594594
**函数签名:**
595595

596596
```typescript
597-
onError(handler: (error: any) => any): () => void
597+
onError(handler: (error: any, to: RouteLocationNormalized, from: RouteLocationNormalized) => any): () => void
598598
```
599599

600600
_参数_
601601

602-
| 参数 | 类型 | 描述 |
603-
| ------- | --------------------- | ------------------ |
604-
| handler | `(error: any) => any` | 要注册的错误处理器 |
602+
| 参数 | 类型 | 描述 |
603+
| ------- | --------------------------------------------------------------------------------- | ------------------------- |
604+
| handler | `(error: any, to: RouteLocationNormalized, from: RouteLocationNormalized) => any` | error handler to register |
605605

606606
### push
607607

@@ -631,8 +631,8 @@ removeRoute(name: string | symbol): void
631631

632632
_参数_
633633

634-
| 参数 | 类型 | 描述 |
635-
| ---- | ------- | ------- |
634+
| 参数 | 类型 | 描述 |
635+
| ---- | ------------------ | ---------------- |
636636
| name | `string \| symbol` | 要删除的路由名称 |
637637

638638
### replace
@@ -855,12 +855,14 @@ stringifyQuery?: (
855855
如果你想使用函数式组件, 请确保在组件上添加一个 `displayName`
856856

857857
例如:
858+
858859
```js
859860
const HomeView = () => h('div', 'HomePage')
860861
// 使用TypeScript时, 组件需要为 FunctionalComponent 类型
861862
HomeView.displayName = 'HomeView'
862863
const routes = [{ path: '/', component: HomeView }]
863864
```
865+
864866
:::
865867

866868
## RouteRecordNormalized

0 commit comments

Comments
 (0)