From: Eduardo San Martin Morote Date: Tue, 20 Jun 2023 14:49:44 +0000 (+0200) Subject: docs: params X-Git-Tag: v4.2.3~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b480bd1d6ffe6a525e1869112e90a49322ecac02;p=thirdparty%2Fvuejs%2Frouter.git docs: params --- diff --git a/packages/docs/guide/essentials/navigation.md b/packages/docs/guide/essentials/navigation.md index 14ab4a24..acb7fa36 100644 --- a/packages/docs/guide/essentials/navigation.md +++ b/packages/docs/guide/essentials/navigation.md @@ -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. @@ -70,7 +70,7 @@ It acts like `router.push`, the only difference is that it navigates without pus | --------------------------------- | --------------------- | | `` | `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 }) diff --git a/packages/router/__tests__/router.spec.ts b/packages/router/__tests__/router.spec.ts index 235002f2..a60db539 100644 --- a/packages/router/__tests__/router.spec.ts +++ b/packages/router/__tests__/router.spec.ts @@ -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' } }) @@ -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: '' })