Vue實(shí)現(xiàn)側(cè)邊菜單欄手風(fēng)琴效果實(shí)例代碼
效果圖如下所示:


<template>
<div class="asideBox">
<aside>
<ul class="asideMenu">
<li v-for="(item,index) in menuList">
<div class="oneMenu" @click="showToggle(item,index)">
<img v-bind:src="item.imgUrl" />
<span>{{item.name}}</span>
</div>
<ul v-show="item.isSubShow">
<li v-for="subItem in item.subItems">
<div class="oneMenuChild">{{subItem.name}}</div>
</li>
</ul>
</li>
</ul>
</aside>
</div>
</template>
export default {
data(){
return{
menuList:[
{
name:'字符錄入',
imgUrl:require('../assets/images/icon-character.png'),
isSubShow:false,
subItems:[
{
name:'字符錄入'
},
{
name:'白話文錄入'
},
{
name:'文言文錄入'
},
{
name:'小寫數(shù)字錄入'
}
]
},
{
name:'票據(jù)數(shù)據(jù)錄入',
imgUrl:require('../assets/images/icon-bill.png'),
isSubShow:false,
subItems:[
{
name:'票據(jù)錄入'
},
{
name:'翻打傳票'
},
]
},
{
name:'交易碼錄入',
imgUrl:require('../assets/images/icon-transaction.png'),
isSubShow:false,
subItems:[
{
name:'交易碼錄入'
},
{
name:'交易名稱錄入'
},
]
},
{
name:'操作碼錄入',
imgUrl:require('../assets/images/icon-operation.png'),
isSubShow:false,
subItems:[
{
name:'操作碼錄入'
},
{
name:'操作名稱錄入'
},
]
},
{
name:'票據(jù)學(xué)習(xí)',
imgUrl:require('../assets/images/icon-billearn.png'),
isSubShow:false,
subItems:[
]
},
{
name:'內(nèi)部憑證學(xué)習(xí)',
imgUrl:require('../assets/images/icon-voucher.png'),
isSubShow:false,
subItems:[
]
},
{
name:'現(xiàn)金管理學(xué)習(xí)',
imgUrl:require('../assets/images/icon-cash.png'),
isSubShow:false,
subItems:[
]
},
]
}
},
methods:{
// 點(diǎn)擊展開折疊菜單事件
showToggle:function(item,ind){
this.menuList.forEach(i => {
// 判斷如果數(shù)據(jù)中的menuList[i]的show屬性不等于當(dāng)前數(shù)據(jù)的isSubShow屬性那么menuList[i]等于false
if (i.isSubShow !== this.menuList[ind].isSubShow) {
i.isSubShow = false;
}
});
item.isSubShow = !item.isSubShow;
console.log(item.name)
},
}
}
<style lang="scss" scoped>
$menuBackColor:#f1f1f1;
$menuListH2:#8fbfef;
.asideBox{
height: 100%;
width: 300px;
aside{
background: $menuBackColor;
height: 100%;
.asideMenu{
.oneMenu{
height: 50px;
line-height: 50px;
font-size: 18px;
font-weight: normal;
color: #ffffff;
background: $menuListH2 url("../assets/images/icon-open.png") no-repeat 280px center;
border-bottom: 1px solid #669cd9;
img{
width: 20px;
height: 20px;
margin: 15px 16px 15px 20px;
vertical-align: top;
}
}
.oneMenuChild{
padding: 0 20px 0 60px;
height: 40px;
line-height: 40px;
background: $menuBackColor;
border-bottom: 1px solid #ffffff;
color: #454343;
font-size: 18px;
}
}
}
}
</style>
總結(jié)
以上所述是小編給大家介紹的Vue實(shí)現(xiàn)側(cè)邊菜單欄手風(fēng)琴效果實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
VueX?mapGetters獲取Modules中的Getters方式
這篇文章主要介紹了VueX?mapGetters獲取Modules中的Getters方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08
vue3之Suspense加載異步數(shù)據(jù)的使用
本文主要介紹了vue3之Suspense加載異步數(shù)據(jù)的使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-02-02
解決vue腳手架項(xiàng)目打包后路由視圖不顯示的問題
今天小編就為大家分享一篇解決vue腳手架項(xiàng)目打包后路由視圖不顯示的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-09-09
Vue下載Excel后報(bào)錯(cuò),或打不開的解決
這篇文章主要介紹了Vue下載Excel后報(bào)錯(cuò),或打不開的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-02-02
vue對(duì)象或者數(shù)組中數(shù)據(jù)變化但是視圖沒有更新問題及解決
這篇文章主要介紹了vue對(duì)象或者數(shù)組中數(shù)據(jù)變化但是視圖沒有更新問題及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-07-07
Vue-router編程式導(dǎo)航的兩種實(shí)現(xiàn)代碼
這篇文章主要介紹了Vue-router編程式導(dǎo)航的實(shí)現(xiàn)代碼,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-03-03
antd+vue實(shí)現(xiàn)動(dòng)態(tài)驗(yàn)證循環(huán)屬性表單的思路
今天通過本文給大家分享antd+vue實(shí)現(xiàn)動(dòng)態(tài)驗(yàn)證循環(huán)屬性表單的思路,代碼簡單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2021-09-09
vue路由守衛(wèi)及路由守衛(wèi)無限循環(huán)問題詳析
這篇文章主要給大家介紹了關(guān)于vue路由守衛(wèi)及路由守衛(wèi)無限循環(huán)問題的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09

