您好,登錄后才能下訂單哦!
效果圖如下所示:
<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)站的支持!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。