Skip to content

Commit 704d790

Browse files
committed
初始化路由
1 parent c51f9b6 commit 704d790

File tree

8 files changed

+52
-18
lines changed

8 files changed

+52
-18
lines changed

zhiwei-ui-vue3/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
</head>
99
<body>
1010
<div id="app"></div>
11-
<script type="module" src="/src/main.js"></script>
11+
<script type="module" src="/src/main.ts"></script>
1212
</body>
1313
</html>

zhiwei-ui-vue3/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
"build": "vite build"
77
},
88
"dependencies": {
9-
"vue": "^3.0.0-rc.1"
9+
"vue": "^3.0.0-rc.1",
10+
"vue-router": "4.0.12"
1011
},
1112
"devDependencies": {
12-
"vite": "^1.0.0-rc.1",
13-
"@vue/compiler-sfc": "^3.0.0-rc.1"
13+
"@vue/compiler-sfc": "^3.0.0-rc.1",
14+
"vite": "^1.0.0-rc.1"
1415
}
15-
}
16+
}

zhiwei-ui-vue3/src/App.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<template>
2-
<img alt="Vue logo" src="./assets/logo.png" />
3-
<HelloWorld msg="Hello Vue 3.0 + Vite" />
2+
<div>导航栏</div>
3+
<router-link to="/">首页</router-link>
4+
<router-link to="/jam">jam</router-link>
5+
<hr/>
6+
<router-view />
47
</template>
58

69
<script>
7-
import HelloWorld from './components/HelloWorld.vue'
8-
910
export default {
10-
name: 'App',
11-
components: {
12-
HelloWorld
13-
}
11+
name: 'App'
1412
}
1513
</script>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div>
3+
jam22222~
4+
</div>
5+
</template>

zhiwei-ui-vue3/src/main.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

zhiwei-ui-vue3/src/main.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
import './index.css'
4+
import { createWebHashHistory,createRouter } from 'vue-router'
5+
import Jam from './components/Jam.vue'
6+
import Jam2 from './components/Jam2.vue'
7+
const history = createWebHashHistory()
8+
const router = createRouter({
9+
history:history,
10+
routes:[
11+
{ path:'/',component:Jam },
12+
{ path:'/jam',component:Jam2 },
13+
]
14+
})
15+
16+
const app = createApp(App)
17+
app.use(router)
18+
app.mount('#app')

zhiwei-ui-vue3/src/shims-vue.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module '*.vue' {
2+
import { ComponentOptions } from 'vue'
3+
const componentOptions: ComponentOptions
4+
export default componentOptions
5+
}

zhiwei-ui-vue3/yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,11 @@
296296
"@vue/compiler-dom" "3.2.31"
297297
"@vue/shared" "3.2.31"
298298

299+
"@vue/devtools-api@^6.0.0-beta.18":
300+
version "6.1.3"
301+
resolved "https://registry.npmmirror.com/@vue/devtools-api/-/devtools-api-6.1.3.tgz#a44c52e8fa6d22f84db3abdcdd0be5135b7dd7cf"
302+
integrity sha512-79InfO2xHv+WHIrH1bHXQUiQD/wMls9qBk6WVwGCbdwP7/3zINtvqPNMtmSHXsIKjvUAHc8L0ouOj6ZQQRmcXg==
303+
299304
"@vue/reactivity-transform@3.2.31":
300305
version "3.2.31"
301306
resolved "https://registry.npmmirror.com/@vue/reactivity-transform/-/reactivity-transform-3.2.31.tgz#0f5b25c24e70edab2b613d5305c465b50fc00911"
@@ -1839,6 +1844,13 @@ vite@^1.0.0-rc.1:
18391844
vue "^3.0.3"
18401845
ws "^7.3.1"
18411846

1847+
vue-router@4.0.12:
1848+
version "4.0.12"
1849+
resolved "https://registry.npmmirror.com/vue-router/-/vue-router-4.0.12.tgz#8dc792cddf5bb1abcc3908f9064136de7e13c460"
1850+
integrity sha512-CPXvfqe+mZLB1kBWssssTiWg4EQERyqJZes7USiqfW9B5N2x+nHlnsM1D3b5CaJ6qgCvMmYJnz+G0iWjNCvXrg==
1851+
dependencies:
1852+
"@vue/devtools-api" "^6.0.0-beta.18"
1853+
18421854
vue@^3.0.0-rc.1, vue@^3.0.3:
18431855
version "3.2.31"
18441856
resolved "https://registry.npmmirror.com/vue/-/vue-3.2.31.tgz#e0c49924335e9f188352816788a4cca10f817ce6"

0 commit comments

Comments
 (0)