vue3实现折叠面板

发布时间:2024-12-06 08:57

厨房墙面安装可折叠的菜板 #生活技巧# #居家实用技巧# #节省家居空间方法#

说学逗唱攻城狮 已于 2023-07-06 09:48:38 修改

于 2023-07-06 09:21:29 首次发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

在这里插入图片描述
总是忘记vue怎么实现折叠面板,记录一下,没有动画样式。

<div class="item-content padding15" style="font-size: 0.875rem;" @click="changeCollapse(index)" v-for="(item, index) in collData.dataList" :key="index" ><div class="flex justify-between items-center"> <div> <span style="color: var(--fontColor);">{{ item.first }}</span>至 <span style="color: var(--fontColor);">{{ item.last }}</span>(8) </div> <el-icon v-if="collData.activeIndex.indexOf(index) != -1"><ArrowDown color="#262626" /></el-icon> <el-icon v-else><ArrowRight color="#262626" /></el-icon></div><div class="gradient-wrapper" :class="collData.activeIndex.indexOf(index) != -1?'active':''"> <div class="marginT20" v-for="(org, ind) in item.orgList" :key="ind"> <div class="flex justify-between items-center padding10 marginB15 item-get-org"> <div class="item-get-name ellipsis">{{ org.name }}({{ org.unitName }})</div> <el-icon :size="18" class="pointer"><CircleClose color="#AAAAAA" /></el-icon> </div> </div></div></div> <script setup> import {ref, reactive} from "vue"; const collData = reactive({ dataList: [{ first: 'k2', last: 'k12', orgList: [{ name: '张三', unitName: '某某单位' }] }, { first: 'k2', last: 'k12', orgList: [{ name: '张三2', unitName: '某某单位' }] }], activeIndex: [] }) const changeCollapse = (index) => { if (collData.activeIndex.indexOf(index) == -1) { collData.activeIndex.push(index) } else { collData.activeIndex = collData.activeIndex.filter(item => item != index) } } </script> <style scoped> .item-content { margin: 15px 0; background: #f8f8f8; border-radius: 4px; } .item-unit-add { display: flex; flex-wrap: wrap; padding: 10px 0; } .item-unit { padding-left: 15px; padding-right: 10px; margin: 5px; width: 96px; height: 40px; line-height: 40px; background: #F4F4F4; border: 1px solid #AAAAAA; border-radius: 4px; font-size: 0.875rem; } .item-get-org { background: #F4F4F4; border: 1px solid #AAAAAA; border-radius: 4px; font-size: 0.875rem; } .item-get-org:last-child { margin-bottom: 0; } .item-get-name { width: 80%; } .gradient-wrapper { height: 0; overflow: hidden; } .gradient-wrapper.active { height: 100%; transition: height .3s ease-in; transform-origin: 50% 0; animation: slide-down 0.3s ease-in; -webkit-animation: slide-down 0.3s ease-in; } @keyframes slide-down { 0% { opacity: 0; } 30% { opacity: .3; } 60% { opacity: .6; } 100% { opacity: .6; } } @-webkit-keyframes slide-down { 0% { opacity: 0; } 30% { topacity: .3; } 60% { opacity: .6; } 100% { opacity: .6; } } </style>

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127

网址:vue3实现折叠面板 https://www.yuejiaxmz.com/news/view/394037

相关内容

超实用!折叠式沥水砧板
一种可折叠的多功能切菜板.pdf
【厨房折叠门】厨房折叠门价格表
一种带吸盘的伸缩式折叠案板的制作方法
使用script setup语法糖优化你的vue3代码
Fozzils再添折叠餐具新品
没用的东西又+1 小米发布米家折叠暖菜板
厨房多功能折叠桌
一种便携式可折叠桌面分隔器专利查询
好餐聚 多功能折叠切菜板 14.9元(需用券)

随便看看