Skip to content

Commit 8e6b851

Browse files
authored
try to fix #3974
1 parent 9f7f591 commit 8e6b851

File tree

1 file changed

+34
-53
lines changed

1 file changed

+34
-53
lines changed

src/runtime/inertia/components/Link.vue

+34-53
Original file line numberDiff line numberDiff line change
@@ -110,72 +110,53 @@ const linkClass = computed(() => {
110110
})
111111
112112
const page = usePage()
113-
const url = computed(() => props.to ?? props.href ?? '#')
113+
const url = computed(() => props.to ?? props.href ?? '')
114114
115115
const isActive = computed(() => props.active || (props.exact ? url.value === props.href : page?.url.startsWith(url.value)))
116116
</script>
117117

118118
<template>
119-
<template v-if="!isExternal">
120-
<InertiaLink v-bind="routerLinkProps" :href="url" custom>
121-
<template v-if="custom">
122-
<slot
123-
v-bind="{
124-
...$attrs,
125-
as,
126-
type,
127-
disabled,
128-
href: url,
129-
active: isActive
130-
}"
131-
/>
132-
</template>
133-
<ULinkBase
134-
v-else
135-
v-bind="{
136-
...$attrs,
137-
as,
138-
type,
139-
disabled,
140-
href: url,
141-
active: isActive
142-
}"
143-
:class="linkClass"
144-
>
145-
<slot :active="isActive" />
146-
</ULinkBase>
147-
</InertiaLink>
148-
</template>
149-
150-
<template v-else>
151-
<template v-if="custom">
152-
<slot
153-
v-bind="{
154-
...$attrs,
155-
as,
156-
type,
157-
disabled,
158-
href: to,
159-
target: isExternal ? '_blank' : undefined,
160-
active: isActive
161-
}"
162-
/>
163-
</template>
164-
<ULinkBase
165-
v-else
119+
<InertiaLink v-if="!isExternal && custom && !!url" v-bind="routerLinkProps" :href="url">
120+
<slot
166121
v-bind="{
167122
...$attrs,
168123
as,
169124
type,
170125
disabled,
171126
href: url,
127+
active: isActive
128+
}"
129+
/>
130+
</InertiaLink>
131+
132+
<template v-else-if="custom">
133+
<slot
134+
v-bind="{
135+
...$attrs,
136+
as,
137+
type,
138+
disabled,
139+
href: to,
172140
target: isExternal ? '_blank' : undefined,
173141
active: isActive
174142
}"
175-
:is-external="isExternal"
176-
:class="linkClass"
177-
>
178-
<slot :active="isActive" />
179-
</ULinkBase>
143+
/>
180144
</template>
145+
146+
<ULinkBase
147+
v-else
148+
v-bind="{
149+
...$attrs,
150+
as,
151+
type,
152+
disabled,
153+
href: url,
154+
target: isExternal ? '_blank' : undefined,
155+
active: isActive
156+
}"
157+
:is-external="isExternal"
158+
:class="linkClass"
159+
>
160+
<slot :active="isActive" />
161+
</ULinkBase>
181162
</template>

0 commit comments

Comments
 (0)