添加路由,配置@根目录
This commit is contained in:
parent
f1f5056209
commit
844c203015
@ -9,7 +9,8 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vue": "^3.5.24"
|
"vue": "^3.5.24",
|
||||||
|
"vue-router": "^4.6.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^24.10.1",
|
"@types/node": "^24.10.1",
|
||||||
|
|||||||
18
pnpm-lock.yaml
generated
18
pnpm-lock.yaml
generated
@ -11,6 +11,9 @@ importers:
|
|||||||
vue:
|
vue:
|
||||||
specifier: ^3.5.24
|
specifier: ^3.5.24
|
||||||
version: 3.5.26(typescript@5.9.3)
|
version: 3.5.26(typescript@5.9.3)
|
||||||
|
vue-router:
|
||||||
|
specifier: ^4.6.4
|
||||||
|
version: 4.6.4(vue@3.5.26(typescript@5.9.3))
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^24.10.1
|
specifier: ^24.10.1
|
||||||
@ -542,6 +545,9 @@ packages:
|
|||||||
'@vue/compiler-ssr@3.5.26':
|
'@vue/compiler-ssr@3.5.26':
|
||||||
resolution: {integrity: sha512-lZT9/Y0nSIRUPVvapFJEVDbEXruZh2IYHMk2zTtEgJSlP5gVOqeWXH54xDKAaFS4rTnDeDBQUYDtxKyoW9FwDw==}
|
resolution: {integrity: sha512-lZT9/Y0nSIRUPVvapFJEVDbEXruZh2IYHMk2zTtEgJSlP5gVOqeWXH54xDKAaFS4rTnDeDBQUYDtxKyoW9FwDw==}
|
||||||
|
|
||||||
|
'@vue/devtools-api@6.6.4':
|
||||||
|
resolution: {integrity: sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==}
|
||||||
|
|
||||||
'@vue/devtools-core@8.0.5':
|
'@vue/devtools-core@8.0.5':
|
||||||
resolution: {integrity: sha512-dpCw8nl0GDBuiL9SaY0mtDxoGIEmU38w+TQiYEPOLhW03VDC0lfNMYXS/qhl4I0YlysGp04NLY4UNn6xgD0VIQ==}
|
resolution: {integrity: sha512-dpCw8nl0GDBuiL9SaY0mtDxoGIEmU38w+TQiYEPOLhW03VDC0lfNMYXS/qhl4I0YlysGp04NLY4UNn6xgD0VIQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@ -909,6 +915,11 @@ packages:
|
|||||||
vscode-uri@3.1.0:
|
vscode-uri@3.1.0:
|
||||||
resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==}
|
resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==}
|
||||||
|
|
||||||
|
vue-router@4.6.4:
|
||||||
|
resolution: {integrity: sha512-Hz9q5sa33Yhduglwz6g9skT8OBPii+4bFn88w6J+J4MfEo4KRRpmiNG/hHHkdbRFlLBOqxN8y8gf2Fb0MTUgVg==}
|
||||||
|
peerDependencies:
|
||||||
|
vue: ^3.5.0
|
||||||
|
|
||||||
vue-tsc@3.2.2:
|
vue-tsc@3.2.2:
|
||||||
resolution: {integrity: sha512-r9YSia/VgGwmbbfC06hDdAatH634XJ9nVl6Zrnz1iK4ucp8Wu78kawplXnIDa3MSu1XdQQePTHLXYwPDWn+nyQ==}
|
resolution: {integrity: sha512-r9YSia/VgGwmbbfC06hDdAatH634XJ9nVl6Zrnz1iK4ucp8Wu78kawplXnIDa3MSu1XdQQePTHLXYwPDWn+nyQ==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
@ -1382,6 +1393,8 @@ snapshots:
|
|||||||
'@vue/compiler-dom': 3.5.26
|
'@vue/compiler-dom': 3.5.26
|
||||||
'@vue/shared': 3.5.26
|
'@vue/shared': 3.5.26
|
||||||
|
|
||||||
|
'@vue/devtools-api@6.6.4': {}
|
||||||
|
|
||||||
'@vue/devtools-core@8.0.5(vite@7.3.1(@types/node@24.10.8))(vue@3.5.26(typescript@5.9.3))':
|
'@vue/devtools-core@8.0.5(vite@7.3.1(@types/node@24.10.8))(vue@3.5.26(typescript@5.9.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@vue/devtools-kit': 8.0.5
|
'@vue/devtools-kit': 8.0.5
|
||||||
@ -1748,6 +1761,11 @@ snapshots:
|
|||||||
|
|
||||||
vscode-uri@3.1.0: {}
|
vscode-uri@3.1.0: {}
|
||||||
|
|
||||||
|
vue-router@4.6.4(vue@3.5.26(typescript@5.9.3)):
|
||||||
|
dependencies:
|
||||||
|
'@vue/devtools-api': 6.6.4
|
||||||
|
vue: 3.5.26(typescript@5.9.3)
|
||||||
|
|
||||||
vue-tsc@3.2.2(typescript@5.9.3):
|
vue-tsc@3.2.2(typescript@5.9.3):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@volar/typescript': 2.4.27
|
'@volar/typescript': 2.4.27
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
holle word
|
<router-view></router-view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
10
src/main.ts
10
src/main.ts
@ -1,5 +1,5 @@
|
|||||||
import { createApp } from 'vue'
|
import { createApp } from "vue";
|
||||||
import './style.css'
|
import App from "./App.vue";
|
||||||
import App from './App.vue'
|
import router from "./router";
|
||||||
|
const app = createApp(App);
|
||||||
createApp(App).mount('#app')
|
app.use(router).mount("#app");
|
||||||
|
|||||||
15
src/router/index.ts
Normal file
15
src/router/index.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { createMemoryHistory, createRouter } from "vue-router";
|
||||||
|
import HomeView from "@/views/home/index.vue";
|
||||||
|
import AboutView from "@/views/login/index.vue";
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
{ path: "/", component: HomeView },
|
||||||
|
{ path: "/login", component: AboutView },
|
||||||
|
];
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createMemoryHistory(),
|
||||||
|
routes,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default router;
|
||||||
6
src/views/home/index.vue
Normal file
6
src/views/home/index.vue
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<script setup lang='ts'></script>
|
||||||
|
<template>
|
||||||
|
<h1>首页</h1>
|
||||||
|
<router-link to="/login">登录</router-link>
|
||||||
|
</template>
|
||||||
|
<style scoped></style>
|
||||||
5
src/views/login/index.vue
Normal file
5
src/views/login/index.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<script setup lang='ts'></script>
|
||||||
|
<template>
|
||||||
|
<h1>登录页</h1>
|
||||||
|
</template>
|
||||||
|
<style lang='scss' scoped></style>
|
||||||
@ -12,5 +12,5 @@
|
|||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"noUncheckedSideEffectImports": true
|
"noUncheckedSideEffectImports": true
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
|
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "vite-env.d.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,5 +3,11 @@
|
|||||||
"references": [
|
"references": [
|
||||||
{ "path": "./tsconfig.app.json" },
|
{ "path": "./tsconfig.app.json" },
|
||||||
{ "path": "./tsconfig.node.json" }
|
{ "path": "./tsconfig.node.json" }
|
||||||
]
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
7
vite-env.d.ts
vendored
Normal file
7
vite-env.d.ts
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
declare module '*.vue' {
|
||||||
|
import type { DefineComponent } from 'vue'
|
||||||
|
const component: DefineComponent<{}, {}, any>
|
||||||
|
export default component
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user