Skip to content

Commit d0cce25

Browse files
committed
docs: wip useLink
1 parent ff6e026 commit d0cce25

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

docs/guide/advanced/extending-router-link.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ export default {
5757
},
5858

5959
setup(props) {
60-
const useLink
61-
const isExternalLink = computed(() => typeof props.to === 'string' && props.to.startsWith('http'))
60+
const { navigate, href route, isActive, isExactActive } = useLink(toRef(props, 'to'))
61+
62+
63+
// profit!
6264

6365
return { isExternalLink }
6466
}

test-dts/navigationGuards.test-d.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
import { createRouter, createWebHistory, expectType } from './index'
2-
import { NavigationFailure } from 'dist/vue-router'
1+
import {
2+
createRouter,
3+
createWebHistory,
4+
expectType,
5+
isNavigationFailure,
6+
NavigationFailure,
7+
NavigationFailureType,
8+
RouteLocationNormalized,
9+
RouteLocationRaw,
10+
} from './index'
311

412
const router = createRouter({
513
history: createWebHistory(),
@@ -34,4 +42,12 @@ router.beforeEach((to, from, next) => {
3442

3543
router.afterEach((to, from, failure) => {
3644
expectType<NavigationFailure | undefined | void>(failure)
45+
if (isNavigationFailure(failure)) {
46+
expectType<RouteLocationNormalized>(failure.from)
47+
expectType<RouteLocationRaw>(failure.to)
48+
}
49+
if (isNavigationFailure(failure, NavigationFailureType.cancelled)) {
50+
expectType<RouteLocationNormalized>(failure.from)
51+
expectType<RouteLocationRaw>(failure.to)
52+
}
3753
})

0 commit comments

Comments
 (0)