Vue3 全局路由的使用

一. App.vue



二. main.js

import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'

createApp(App).use(router).mount('#app')

三. /router/index.js

import {createRouter, createWebHistory} from 'vue-router'

const drawDot = () => import('@/components/map/drawDot.vue')

const routes = [
  {
    path: '/map/drawDot',
    component: drawDot
  }
]
const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router

你可能感兴趣的:(#,L4:Vue,vue3,全局router引用)