安装
npm install vue-router@3.6.5 --save
2 引入-注册-创建路由
import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'
createApp(App).use(router).mount('#app')
增加JS /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