一. App.vue
<template>
<router-view/>
</template>
<script>
export default {
name: 'App',
components: {
}
}
</script>
二. 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
文章来源地址https://www.toymoban.com/news/detail-684757.html
文章来源:https://www.toymoban.com/news/detail-684757.html
到了这里,关于Vue3 全局路由的使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!