Skip to content

Commit 32c8853

Browse files
committed
fix(NcFormBoxButton): router check on Vue 2
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
1 parent 91f4cda commit 32c8853

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/composables/useButtonLink.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { MaybeRef } from '@vueuse/core'
77
import type { AnchorHTMLAttributes, ButtonHTMLAttributes } from 'vue'
88
import type { RawLocation } from 'vue-router'
99

10-
import Vue, { computed, reactive } from 'vue'
10+
import { computed, getCurrentInstance, reactive } from 'vue'
1111

1212
type ButtonLinkProps = {
1313
// Required - general link props
@@ -65,7 +65,8 @@ export function useButtonLink(options: ButtonLinkProps) {
6565
// Resolve all MaybeRef-s values and maybe reactive object via unwrapping
6666
const props = reactive(options)
6767

68-
const hasVueRouterContext = Vue.prototype.$router !== undefined
68+
const instance = getCurrentInstance()!
69+
const hasVueRouterContext = '$router' in instance.proxy.$root
6970

7071
/**
7172
* Tag name to be used

0 commit comments

Comments
 (0)