学习路由!
This commit is contained in:
@@ -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");
|
Reference in New Issue
Block a user