菜单跳转

This commit is contained in:
朱进禄 2021-12-21 17:48:15 +08:00
parent ab7a06069a
commit e61b6091f1
3 changed files with 42 additions and 14 deletions

View File

@ -2,18 +2,10 @@
<router-view class="dark"></router-view> <router-view class="dark"></router-view>
<div class="menu-wrapper"> <div class="menu-wrapper">
<span class="iconfont icon-settings" :class="{active: menuShow}" @click="menuShow = !menuShow"></span> <span class="iconfont icon-settings" :class="{active: menuShow}" @click="menuShow = !menuShow"></span>
<div class="menu-list" :style="{width: menuShow ? '180px' : 0}"> <div class="menu-list" :style="{width: menuShow ? '180px' : '10px'}">
<div class="menu-item"> <div class="menu-item" v-for="(item,index) in menus" :key="index" @click="toPath(item.routeName)">
<span class="iconfont icon-home"></span> <span class="iconfont" :class="item.icon"></span>
<div>首页</div> <div>{{ item.name }}</div>
</div>
<div class="menu-item">
<span class="iconfont icon-compass"></span>
<div>视迹</div>
</div>
<div class="menu-item">
<span class="iconfont icon-record"></span>
<div>观呼吸</div>
</div> </div>
</div> </div>
</div> </div>
@ -24,7 +16,28 @@ export default {
name: 'App', name: 'App',
data() { data() {
return { return {
menuShow: false menuShow: false,
menus: [{
icon: 'icon-home',
name: '首页',
routeName: 'Guide'
},{
icon: 'icon-compass',
name: '视迹',
routeName: 'History'
},{
icon: 'icon-record',
name: '观呼吸'
}]
}
},
methods: {
toPath(routeName) {
if(!routeName) {
return
}
this.$router.push({name: routeName})
this.menuShow = false
} }
} }
} }
@ -96,7 +109,7 @@ body {
position: absolute; position: absolute;
left: 0; left: 0;
top: 0; top: 0;
padding-left: 50px; padding-left: 40px;
padding-bottom: 6px; padding-bottom: 6px;
padding-top: 4px; padding-top: 4px;
background-color: #FFF; background-color: #FFF;

View File

@ -2,10 +2,12 @@ import { createRouter, createWebHashHistory } from 'vue-router'
import Guide from '@/views/Guide.vue' import Guide from '@/views/Guide.vue'
import Introduce from '@/views/Introduce.vue' import Introduce from '@/views/Introduce.vue'
import History from '@/views/History.vue'
const routes = [ const routes = [
{ path: '/', name: 'Guide', component: Guide }, { path: '/', name: 'Guide', component: Guide },
{ path: '/introduce', name: 'Introduce', component: Introduce }, { path: '/introduce', name: 'Introduce', component: Introduce },
{ path: '/history', name: 'History', component: History },
] ]
export default createRouter({ export default createRouter({

13
src/views/History.vue Normal file
View File

@ -0,0 +1,13 @@
<template>
<div>这是历史记录页面</div>
</template>
<script>
export default {
}
</script>
<style>
</style>