基于vue的列表手风琴

html

2018-05-3011:15:36

 

 
js
openList: function(e){
let self = this;
if(this.$(this.$(e.currentTarget)[0].parentElement)[0].className.indexOf('fold') == -1){
this.$(this.$(e.currentTarget)[0].parentElement).addClass('fold')
this.$(e.currentTarget).parent().siblings('.plist').removeClass('fold');
}else{
this.$(this.$(e.currentTarget)[0].parentElement).removeClass('fold')
}

this.groupId = parseInt(this.$(e.currentTarget)[0].id);
this.getdata();
},
 
css
//添加滚动条
#scroll-1{
margin-bottom: .1rem;
height: 4.1rem;
overflow: auto;
}
#scroll-1::-webkit-scrollbar {
width: .05rem;
height: .05rem;
}
#scroll-1::-webkit-scrollbar-button {
background-color: #f3f3f3;
}
#scroll-1::-webkit-scrollbar-track {
background:#f3f3f3;
}
#scroll-1::-webkit-scrollbar-thumb{
background:#969696;
border-radius: .05rem;
}
.accountType{
margin: auto;
padding-bottom: .2rem;
li{
width: 80%;
margin-bottom: 1px;
margin: auto;
}
.lis{
width: 70%;
height: .3rem;
line-height: .3rem;
border-bottom: 1px solid #F4F6F5;
color: #ABAFB2;
// background: red;
margin: auto;
.icon-xiayibu{
float: right;
font-size: 12px;
}
}
.clicks{
background: #29B0E7;
.lis{
border-color: #29B0E7;
color: #fff;
}
}
}

转载于:https://www.cnblogs.com/liangru/p/9109851.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个简单的Vue多级列表实现手风琴的示例代码: ```html <template> <div class="accordion"> <ul> <li v-for="(item, index) in items" :key="index" @click="toggle(index)"> <div class="title">{{ item.title }}</div> <ul v-show="item.show"> <li v-for="(subItem, subIndex) in item.children" :key="subIndex">{{ subItem }}</li> </ul> </li> </ul> </div> </template> <script> export default { data() { return { items: [ { title: "Item 1", show: false, children: ["Subitem 1", "Subitem 2", "Subitem 3"] }, { title: "Item 2", show: false, children: ["Subitem 1", "Subitem 2", "Subitem 3"] }, { title: "Item 3", show: false, children: ["Subitem 1", "Subitem 2", "Subitem 3"] } ] }; }, methods: { toggle(index) { this.items[index].show = !this.items[index].show; this.items.forEach((item, i) => { if (i !== index) { item.show = false; } }); } } }; </script> <style> .accordion { width: 100%; max-width: 500px; margin: 0 auto; } ul { list-style: none; padding: 0; margin: 0; } li { cursor: pointer; } .title { background-color: #eee; padding: 10px; font-weight: bold; } ul ul { background-color: #f9f9f9; padding: 10px; } </style> ``` 在这个示例,我们使用了一个items数组来存储所有的列表项数据。每个列表项包括一个标题和一个级菜单,级菜单是一个字符串数组。我们使用v-for指令来遍历items数组,渲染每个列表项,并且使用v-show指令来控制级菜单的显示和隐藏。 在toggle方法,我们使用了一个简单的算法来实现手风琴效果。当用户点击某个列表项时,我们将该列表项的show属性设置为true,同时将其他列表项的show属性设置为false,这样就能保证只有一个级菜单处于展开状态。 最后,我们还添加了一些基本的样式来美化手风琴效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值