• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

vue2.0 可折叠列表 v-for循环展示的实例

vue 搞代码 4年前 (2022-01-08) 44次浏览 已收录 0个评论

今天小编大家分享一篇vue2.0 可折叠列表 v-for循环展示的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

先上一张效果图:

以前用angularjs操作基本上都是要取到每个列表的id再循环判断是不是当前点击的列表来显示折叠。

今天在这个项目 https://github.com/IFmiss/vue-music 上看到操作很简单,并没有如此复杂。赶紧记录一下:

折叠列表单独做一个组件,图标是用的iconfont中生成的css链接:myMusicSheetList.vue

  <div class="sheet-list"> <div class="sheet-header"> <i class="icon iconfont icon-enter"></i><span class="sheet-header-span">{{data_item.name}} <span> ({{data_item.num}}) </span></span><i class="sheet-header-i icon iconfont icon-setup"></i></div><div class="sheet-content"> <div class="sheet-content-image"> </div><div class="sheet-content-middle"> <p>{{i.details_name}}</p><p style="margin-top: 10px;font-size: 14px;color: #666">{{i.details_num}}首歌曲</p></div><i class="icon iconfont icon-switch"></i></div></div>
 
  .sheet-list{ clear: both; } .sheet-header{ height: 30px;background: #e5e5e5;position: relative; } .sheet-header i:nth-child(1){ line-height: 30px;position:absolute; left:10px; color:#666; transition:all 0.5s; } .s<div style="color:transparent">本文来源gaodai.ma#com搞##代!^码网(</div>heet-header-i{ line-height: 30px;position: absolute;right: 10px; } .sheet-header-span{ left: 40px;font-size: 14px;position:absolute;line-height: 30px; } .sheet-content{ position: relative;width: 100%;display: flex; } .sheet-content i{ font-size: 26px;position: absolute;right: 10px;top: 50%;transform:translate(0,-50%); } .sheet-content-image{ width: 60px;float: left;text-align: center; } .sheet-content-middle{ position: relative;width: 100%;border-bottom: 1px solid #e5e5e5;padding-bottom: 10px;margin-top: 10px;margin-left: 10px; } .sheet-content-middle p{ font-size: 16px;width: 70%;color: #666;text-overflow:ellipsis;white-space: nowrap;overflow:hidden; } 

主页面调用组件:home.vue

  <div class="home"> </div> 

如果不能运行请检查import 路径是否正确。

以上就是vue2.0 可折叠列表 v-for循环展示的实例的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:vue2.0 可折叠列表 v-for循环展示的实例

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址