mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 01:53:55 +00:00
fix(nuxt): set to.name
to be undefined rather than deleting entirely
This commit is contained in:
parent
ba6a4132bb
commit
4ca1ab7cfb
@ -88,7 +88,7 @@ export interface NuxtLinkProps extends Omit<RouterLinkProps, 'to'> {
|
|||||||
noPrefetch?: boolean
|
noPrefetch?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@__NO_SIDE_EFFECTS__*/
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
export function defineNuxtLink (options: NuxtLinkOptions) {
|
export function defineNuxtLink (options: NuxtLinkOptions) {
|
||||||
const componentName = options.componentName || 'NuxtLink'
|
const componentName = options.componentName || 'NuxtLink'
|
||||||
|
|
||||||
@ -100,7 +100,6 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
|||||||
|
|
||||||
function resolveTrailingSlashBehavior (to: string, resolve: Router['resolve']): string
|
function resolveTrailingSlashBehavior (to: string, resolve: Router['resolve']): string
|
||||||
function resolveTrailingSlashBehavior (to: RouteLocationRaw, resolve: Router['resolve']): Exclude<RouteLocationRaw, string>
|
function resolveTrailingSlashBehavior (to: RouteLocationRaw, resolve: Router['resolve']): Exclude<RouteLocationRaw, string>
|
||||||
function resolveTrailingSlashBehavior (to: undefined, resolve: Router['resolve']): undefined
|
|
||||||
function resolveTrailingSlashBehavior (to: RouteLocationRaw | undefined, resolve: Router['resolve']): RouteLocationRaw | RouteLocation | undefined {
|
function resolveTrailingSlashBehavior (to: RouteLocationRaw | undefined, resolve: Router['resolve']): RouteLocationRaw | RouteLocation | undefined {
|
||||||
if (!to || (options.trailingSlash !== 'append' && options.trailingSlash !== 'remove')) {
|
if (!to || (options.trailingSlash !== 'append' && options.trailingSlash !== 'remove')) {
|
||||||
return to
|
return to
|
||||||
@ -117,6 +116,7 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
|
|||||||
path: applyTrailingSlashBehavior(path, options.trailingSlash)
|
path: applyTrailingSlashBehavior(path, options.trailingSlash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// named routes would otherwise always override trailing slash behavior
|
||||||
if ('name' in resolvedPath) {
|
if ('name' in resolvedPath) {
|
||||||
delete resolvedPath.name
|
delete resolvedPath.name
|
||||||
}
|
}
|
||||||
|
@ -239,7 +239,7 @@ const plugin: Plugin<{ router: Router }> = defineNuxtPlugin({
|
|||||||
try {
|
try {
|
||||||
const to = router.resolve(initialURL)
|
const to = router.resolve(initialURL)
|
||||||
// #4920, #4982
|
// #4920, #4982
|
||||||
if ('name' in to) { delete to.name }
|
if ('name' in to) { to.name = undefined }
|
||||||
await router.replace({
|
await router.replace({
|
||||||
...to,
|
...to,
|
||||||
force: true
|
force: true
|
||||||
|
Loading…
Reference in New Issue
Block a user