菜单跳转

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>
<div class="menu-wrapper">
<span class="iconfont icon-settings" :class="{active: menuShow}" @click="menuShow = !menuShow"></span>
<div class="menu-list" :style="{width: menuShow ? '180px' : 0}">
<div class="menu-item">
<span class="iconfont icon-home"></span>
<div>首页</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 class="menu-list" :style="{width: menuShow ? '180px' : '10px'}">
<div class="menu-item" v-for="(item,index) in menus" :key="index" @click="toPath(item.routeName)">
<span class="iconfont" :class="item.icon"></span>
<div>{{ item.name }}</div>
</div>
</div>
</div>
@ -24,7 +16,28 @@ export default {
name: 'App',
data() {
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;
left: 0;
top: 0;
padding-left: 50px;
padding-left: 40px;
padding-bottom: 6px;
padding-top: 4px;
background-color: #FFF;

View File

@ -2,10 +2,12 @@ import { createRouter, createWebHashHistory } from 'vue-router'
import Guide from '@/views/Guide.vue'
import Introduce from '@/views/Introduce.vue'
import History from '@/views/History.vue'
const routes = [
{ path: '/', name: 'Guide', component: Guide },
{ path: '/introduce', name: 'Introduce', component: Introduce },
{ path: '/history', name: 'History', component: History },
]
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>