学习路由!

This commit is contained in:
2022-11-25 18:07:05 +08:00
parent fe9ac2e09a
commit 20e4ca5f74
6 changed files with 414 additions and 38 deletions

View File

@@ -1,32 +1,26 @@
/*
* @Author: Kane
* @Date: 2022-11-24 01:13:55
* @Date: 2022-11-24 09:08:41
* @LastEditors: Kane
* @LastEditTime: 2022-11-24 09:59:55
* @LastEditTime: 2022-11-25 16:22:52
* @FilePath: \hello-router\src\main.js
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
import { createApp } from "vue";
import { createRouter, createWebHashHistory } from 'vue-router';
// import { createRouter, createWebHashHistory } from "vue-router";
//引入组件
import App from "./App.vue";
import demo1 from "./components/功能页面/demo-1.vue";
import demo2 from "./components/功能页面/demo-2.vue";
import rg from "./components/功能页面/路由守卫.vue";
// import { Header } from "./components/页面组件/Header.vue";
// import { Main } from "./components/页面组件/Main.vue";
// import { demo1 } from "./components/功能页面/demo-1.vue";
// import { demo2 } from "./components/功能页面/demo-2.vue";
const app = createApp(App);
const routes = [
{ path: "/demo-1", component: demo1 },
{ path: "/demo-2", component: demo2 },
{ path: "/user/:username", component: rg }
];
// const routes = [
// {path}
// ];
const router = createRouter({
history: createWebHashHistory(),
routes: routes
})
app.use(router);
app.mount("#app");