Vue2
import Vue from 'vue'
import Router from 'vue-router'
// 定义路由
const routes = [
{
path: '/',
redirect: '/login'
},
{
path: '/login',
name: '登陆',
component: ()=>import('@/components/login/index.vue')
}
]
const router = new Router({
mode: 'history',
routes
})
export default router
Vue3
import {
useRoute,
createRouter,
createWebHistory,
} from "vue-router";
// 定义路由
const routes = [
{
path: '/',
redirect: '/login'
},
{
path: '/login',
name: '登陆',
component: ()=>import('@/components/login/index.vue')
}
]
const router = createRouter({
history: createWebHistory(),
routes
});
export default router;