Skip to content

Commit

Permalink
feat: 增加vue-router
Browse files Browse the repository at this point in the history
  • Loading branch information
yulimchen committed Feb 19, 2021
1 parent 7b97a85 commit 2320803
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 24 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"core-js": "^3.6.5",
"normalize.css": "^8.0.1",
"vant": "^3.0.6",
"vue": "^3.0.5"
"vue": "^3.0.5",
"vue-router": "^4.0.3"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
Expand Down
25 changes: 3 additions & 22 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
<template>
<div>
<img alt="Vue logo" src="./assets/logo.png">
<Dialogue />
<div>
<svg-icon icon-class="checkin" style="font-size: 50px; margin-top: 30px;" />
<div>SVG</div>
</div>
</div>
<router-view />
</template>

<script>
import Dialogue from './components/Dialogue'
export default {
name: 'App',
components: {
Dialogue
}
name: 'App'
}
</script>

<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
3 changes: 2 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createApp } from 'vue'
import router from './router'
import App from './App.vue'

// normalize.css
Expand All @@ -14,4 +15,4 @@ registerVantComp(app)
import { registerSvgIconComp } from '@/plugins/registerSvgIcon'
registerSvgIconComp(app)

app.mount('#app')
app.use(router).mount('#app')
9 changes: 9 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createWebHashHistory, createRouter } from 'vue-router'
import routes from './routes'

const router = createRouter({
history: createWebHashHistory(),
routes
})

export default router
12 changes: 12 additions & 0 deletions src/router/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const routes = [
{
path: '/',
name: 'root',
component: () => import('@/views/Demo'),
children: [

]
}
]

export default routes
31 changes: 31 additions & 0 deletions src/views/Demo/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<div>
<img alt="Vue logo" src="~@/assets/logo.png">
<Dialogue />
<div>
<svg-icon icon-class="checkin" style="font-size: 50px; margin-top: 30px;" />
<div>SVG</div>
</div>
</div>
</template>

<script>
import Dialogue from '@/components/Dialogue'
export default {
name: 'App',
components: {
Dialogue
}
}
</script>

<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
</style>

0 comments on commit 2320803

Please sign in to comment.