vue3:配置路由

93 阅读1分钟

image.png

import { createRouter, createWebHashHistory } from "vue-router";

const login = () => import("../views/LoginView.vue");

 

const routes = [

    { path"/", redirect"/login" },

    {

        path"/login",

        name"login",

        component: login

    }

]
 
/* 使用createRouter创建一个路由对象 */

export const router = createRouter({

    /* 使用哈希模式 */

    historycreateWebHashHistory(),

    routes: routes

})

image.png

image.png