pixelqm
5 years ago
6 changed files with 163 additions and 8 deletions
-
2QMPlusVuePage/src/store/module/router.js
-
39QMPlusVuePage/src/view/layout/aside/asideComponent/index.vue
-
19QMPlusVuePage/src/view/layout/aside/asideComponent/menuItem.vue
-
25QMPlusVuePage/src/view/layout/aside/asideComponent/submenu.vue
-
39QMPlusVuePage/src/view/layout/aside/index.vue
-
47QMPlusVuePage/src/view/layout/index.vue
@ -0,0 +1,39 @@ |
|||
<template> |
|||
<component :is="menuComponent" :routerInfo="routerInfo"> |
|||
<template v-if="routerInfo.children.length"> |
|||
<AsideComponent :key="item.name" :routerInfo="item" v-for="item in routerInfo.children" /> |
|||
</template> |
|||
</component> |
|||
</template> |
|||
|
|||
<script> |
|||
import MenuItem from './menuItem' |
|||
import SubMenu from './submenu' |
|||
|
|||
export default { |
|||
name: 'AsideComponent', |
|||
computed:{ |
|||
menuComponent(){ |
|||
if(this.routerInfo.children.length){ |
|||
return 'SubMenu' |
|||
}else{ |
|||
return 'menuItem' |
|||
} |
|||
} |
|||
}, |
|||
props: { |
|||
routerInfo: { |
|||
default: function() { |
|||
return null |
|||
}, |
|||
type: Object |
|||
} |
|||
}, |
|||
components: { |
|||
MenuItem, |
|||
SubMenu |
|||
} |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
</style> |
@ -0,0 +1,19 @@ |
|||
<template> |
|||
<el-menu-item :index="routerInfo.name">{{routerInfo.meta.title}}</el-menu-item> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name: 'MenuItem', |
|||
props: { |
|||
routerInfo: { |
|||
default: function() { |
|||
return null |
|||
}, |
|||
type: Object |
|||
} |
|||
}, |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
</style> |
@ -0,0 +1,25 @@ |
|||
<template> |
|||
<el-submenu :index="routerInfo.name"> |
|||
<template slot="title"> |
|||
<i class="el-icon-location"></i> |
|||
<span slot="title">{{routerInfo.meta.title}}</span> |
|||
</template> |
|||
<slot></slot> |
|||
</el-submenu> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
name: 'SubMenu', |
|||
props: { |
|||
routerInfo: { |
|||
default: function() { |
|||
return null |
|||
}, |
|||
type: Object |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
<style lang="scss"> |
|||
</style> |
@ -0,0 +1,39 @@ |
|||
<template> |
|||
<el-menu |
|||
mode="vertical" |
|||
:collapse="isCollapse" |
|||
:default-active="active" |
|||
@select="selectMenuItem" |
|||
:class="['el-menu-vertical',!isCollapse&&'noCollapse']" |
|||
> |
|||
<AsideComponent :routerInfo="asyncRouters[0]"/> |
|||
</el-menu> |
|||
</template> |
|||
|
|||
<script> |
|||
import {mapGetters} from 'vuex' |
|||
import AsideComponent from '@/view/layout/aside/asideComponent' |
|||
export default { |
|||
name: 'Aside', |
|||
data() { |
|||
return { |
|||
active: '', |
|||
isCollapse: true |
|||
} |
|||
}, |
|||
methods: { |
|||
selectMenuItem(index) { |
|||
this.$router.push({name:index}) |
|||
} |
|||
}, |
|||
computed:{ |
|||
...mapGetters('router',['asyncRouters']) |
|||
}, |
|||
components: { |
|||
AsideComponent |
|||
}, |
|||
created() { |
|||
this.active = this.$route.name |
|||
} |
|||
} |
|||
</script> |
@ -1,16 +1,49 @@ |
|||
<template> |
|||
<div> |
|||
模板框 |
|||
<router-view></router-view> |
|||
</div> |
|||
<el-container class="layout-cont"> |
|||
<el-header class="header-cont">顶部</el-header> |
|||
<el-container> |
|||
<el-aside class="main-cont main-left"> |
|||
<Aside /> |
|||
</el-aside> |
|||
<el-main class="main-cont main-right"> |
|||
<transition name="el-fade-in-linear" mode="out-in"> |
|||
<router-view></router-view> |
|||
</transition> |
|||
</el-main> |
|||
</el-container> |
|||
</el-container> |
|||
</template> |
|||
|
|||
<script> |
|||
import Aside from '@/view/layout/aside' |
|||
export default { |
|||
name:"Layout" |
|||
name: 'Layout', |
|||
components: { |
|||
Aside |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style scoped> |
|||
|
|||
<style lang="scss"> |
|||
$headerHigh: 52px; |
|||
$mainHight: calc(100vh - 52px); |
|||
.layout-cont { |
|||
.header-cont { |
|||
height: $headerHigh !important; |
|||
background: palevioletred; |
|||
} |
|||
.main-cont { |
|||
.el-menu-vertical { |
|||
min-height: $mainHight !important; |
|||
} |
|||
&::-webkit-scrollbar { |
|||
display: none; |
|||
} |
|||
&.main-left { |
|||
width: auto !important; |
|||
} |
|||
background: blueviolet; |
|||
height: $mainHight !important; |
|||
} |
|||
} |
|||
</style> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue