declare module 27 40vue 2fruntime core 27 24router

Solutions on MaxInterview for declare module 27 40vue 2fruntime core 27 24router by the best coders in the world

showing results for - "declare module 27 40vue 2fruntime core 27 24router"
Lev
13 Oct 2020
1import { createApp } from 'vue'
2import { Router, createRouter } from 'vue-router'
3
4declare module '@vue/runtime-core' {
5  interface ComponentCustomProperties {
6    $router: Router
7  }
8}
9
10// effectively adding the router to every component instance
11const app = createApp({})
12const router = createRouter()
13app.config.globalProperties.$router = router
14
15const vm = app.mount('#app')
16// we can access the router from the instance
17vm.$router.push('/')