Vue實現(xiàn)側邊菜單欄手風琴效果實例代碼
更新時間:2018年05月31日 10:17:38 作者:張三無語
本文通過一段簡單的代碼給大家介紹了基于純vue實現(xiàn)側邊菜單欄手風琴效果,代碼很簡單,感興趣的朋友跟隨腳本之家小編一起看看吧
效果圖如下所示:


<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ù)學習',
imgUrl:require('../assets/images/icon-billearn.png'),
isSubShow:false,
subItems:[
]
},
{
name:'內部憑證學習',
imgUrl:require('../assets/images/icon-voucher.png'),
isSubShow:false,
subItems:[
]
},
{
name:'現(xiàn)金管理學習',
imgUrl:require('../assets/images/icon-cash.png'),
isSubShow:false,
subItems:[
]
},
]
}
},
methods:{
// 點擊展開折疊菜單事件
showToggle:function(item,ind){
this.menuList.forEach(i => {
// 判斷如果數(shù)據(jù)中的menuList[i]的show屬性不等于當前數(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>
總結
以上所述是小編給大家介紹的Vue實現(xiàn)側邊菜單欄手風琴效果實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
相關文章
VueX?mapGetters獲取Modules中的Getters方式
這篇文章主要介紹了VueX?mapGetters獲取Modules中的Getters方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-08-08
vue3之Suspense加載異步數(shù)據(jù)的使用
本文主要介紹了vue3之Suspense加載異步數(shù)據(jù)的使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-02-02
vue對象或者數(shù)組中數(shù)據(jù)變化但是視圖沒有更新問題及解決
這篇文章主要介紹了vue對象或者數(shù)組中數(shù)據(jù)變化但是視圖沒有更新問題及解決,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-07-07
antd+vue實現(xiàn)動態(tài)驗證循環(huán)屬性表單的思路
今天通過本文給大家分享antd+vue實現(xiàn)動態(tài)驗證循環(huán)屬性表單的思路,代碼簡單易懂,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧2021-09-09
vue路由守衛(wèi)及路由守衛(wèi)無限循環(huán)問題詳析
這篇文章主要給大家介紹了關于vue路由守衛(wèi)及路由守衛(wèi)無限循環(huán)問題的相關資料,文中通過示例代碼介紹的非常詳細,對大家學習或者使用vue具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-09-09

