Skip to content

Commit

Permalink
docs: params
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jun 20, 2023
1 parent e6dfcde commit b480bd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/docs/guide/essentials/navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ router.push({ name: 'user', params: { username } }) // -> /user/eduardo
router.push({ path: '/user', params: { username } }) // -> /user
```

When specifying `params`, make sure to either provide a `string` or `number` (or an array of these for [repeatable params](./route-matching-syntax.md#repeatable-params)). **Any other type (like `undefined`, `false`, etc) will be automatically stringified**. For [optional params](./route-matching-syntax.md#optional-parameters), you can provide an empty string (`""`) as the value to skip it.
When specifying `params`, make sure to either provide a `string` or `number` (or an array of these for [repeatable params](./route-matching-syntax.md#repeatable-params)). **Any other type (like objects, booleans, etc) will be automatically stringified**. For [optional params](./route-matching-syntax.md#optional-parameters), you can provide an empty string (`""`) or `null` as the value to remove it.

Since the prop `to` accepts the same kind of object as `router.push`, the exact same rules apply to both of them.

Expand All @@ -70,7 +70,7 @@ It acts like `router.push`, the only difference is that it navigates without pus
| --------------------------------- | --------------------- |
| `<router-link :to="..." replace>` | `router.replace(...)` |

It's also possible to directly add a property `replace: true` to the `routeLocation` that is passed to `router.push`:
It's also possible to directly add a property `replace: true` to the `to` argument that is passed to `router.push`:

```js
router.push({ path: '/home', replace: true })
Expand Down
4 changes: 2 additions & 2 deletions packages/router/__tests__/router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ describe('Router', () => {
await router.push({ name: 'optional', params: {} })
})

it('removes null/undefined params when current location has it', async () => {
it('removes null/undefined optional params when current location has it', async () => {
const { router } = await newRouter()

await router.push({ name: 'optional', params: { p: 'a' } })
Expand All @@ -331,7 +331,7 @@ describe('Router', () => {
expect(router.currentRoute.value.params).toEqual({})
})

it('keeps empty strings', async () => {
it('keeps empty strings in optional params', async () => {
const { router } = await newRouter()
const route1 = router.resolve({ name: 'optional', params: { p: '' } })
expect(route1.params).toEqual({ p: '' })
Expand Down

0 comments on commit b480bd1

Please sign in to comment.