效果图
sass/lsee 转换css 网站 SASS 转 CSS 工具,在线 SASS/SCSS 编译工具 - 在线工具-wetools.com微工具
wxml
<!-- for循环出来的 -->
<view class="problem2">
<view class="problem2-item regular" wx:for="{{questList}}" wx:key="index">
<view class="problem2-item-title" bind:tap="changOpen" data-item="{{item}}" data-index="{{index}}">
<view>
<view>
<image style="width: 32rpx; height: 32rpx;" webp src="{{item.icon1}}" mode="widthFix" />
</view>
<view class="ml-10 b font-14 pr-20">{{item.questions}}</view>
</view>
<view>
<!-- 当前的状态是 true 就是 上箭头 false就是下箭头 当然也可以用本地图片img路径 -->
<image webp src="{{item.t ? item.icon4:item.icon3 }}" mode="widthFix" />
</view>
</view>
<!-- 问题区域 -->
<!-- 选中的下标是否等于 for 循环的下标 -->
<block wx:if="{{showIndex==index}}">
<view class="detailedquestions flex regular mt-10">
<view class="l">
<image src="{{item.icon2}}" mode="widthFix" />
</view>
<view class="r ml-10">
<view class="pr-20 color-827968 font-14">
{{item.answers}}
</view>
</view>
</view>
</block>
</view>
</view>
js文章来源:https://www.toymoban.com/news/detail-523324.html
data:{
// 显示的下标
showIndex: false,
// 数据源
questList: [
{
questions: '是否需要预约?',
answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
t: true,
// icon q
icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
// icon a
icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
// 下箭头
icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
// 上箭头
icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
},
{
questions: '会否出报告?报告是纸质还是电子版的?',
answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
t: false,
// icon q
icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
// icon a
icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
// 下箭头
icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
// 上箭头
icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
},
{
questions: '报告是现场给吗?',
answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
t: false,
// icon q
icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
// icon a
icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
// 下箭头
icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
// 上箭头
icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
},
{
questions: '我的猫狗需要提前准备什么吗?',
answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
t: false,
// icon q
icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
// icon a
icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
// 下箭头
icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
// 上箭头
icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
},
{
questions: '我的猫狗体检的时候,我可以在旁边吗?',
answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
t: false,
// icon q
icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
// icon a
icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
// 下箭头
icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
// 上箭头
icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
},
{
questions: '我的猫狗刚刚做过检查,我可以不重复做同样?',
answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
t: false,
// icon q
icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
// icon a
icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
// 下箭头
icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
// 上箭头
icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
},
{
questions: '我的猫狗在检查过程中发现有比较严重的问题?',
answers: "A:答案内答案内容答案内容答案内容答案内容答案内容答案内容容容答案内容容容答案内容容",
t: false,
// icon q
icon1: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/q.webp',
// icon a
icon2: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Cardiac_ultrasound_examination/a.webp',
// 下箭头
icon3: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/xia.webp',
// 上箭头
icon4: 'https://image.pet.babily.com.cn/public/signed/wushuyi/Insurance_ui/shagn.webp',
}
],
},
// 折叠面板 展开收起的方法
changOpen(e) {
this.data.questList[e.currentTarget.dataset.index].t = !this.data.questList[e.currentTarget.dataset.index].t
this.setData({
questList: this.data.questList
})
if (e.currentTarget.dataset.index != this.data.showIndex) {
// console.log('true的时候');
this.setData({
showIndex: e.currentTarget.dataset.index,
})
}
else {
// console.log('false的时候');
this.setData({
showIndex: 10
})
}
},
wxss文章来源地址https://www.toymoban.com/news/detail-523324.html
.mt-20 {
margin-top: 40rpx;
}
.mt-10 {
margin-top: 20rpx;
}
.ml-10 {
margin-left: 20rpx;
}
.mb-20 {
margin-bottom: 40rpx;
}
.ml-10 {
margin-left: 20rpx;
}
.b {
font-weight: bold;
}
.font-14 {
font-size: 28rpx;
}
.pr-20 {
padding-right: 40rpx;
}
.flex{
display: flex;
}
.problem2 {
min-height: 0rpx;
background-color: #fff;
margin: 20rpx;
margin-top: 40rpx;
border-radius: 40rpx;
padding: 34rpx;
// 每一项
.problem2-item {
border-bottom: 1px solid #f5f3ed;
padding: 30rpx 0;
// 标题
.problem2-item-title {
display: flex;
justify-content: space-between;
>view:nth-child(1) {
display: flex;
>view:nth-child(1) {
margin-top: 2rpx;
width: 32rpx;
border-radius: 50%;
image {
width: 100%;
height: 100%;
}
}
}
>view:nth-child(2) {
width: 11px;
height: 6px;
border: 50%;
image {
width: 100%;
height: 100%;
}
}
}
// 问题区域
.detailedquestions {
border-right-color: seagreen;
.l {
margin-top: 10rpx;
width: 32rpx;
height: 32rpx;
// background-color: pink;
image {
width: 32rpx;
height: 32rpx;
}
}
}
}
}
到了这里,关于微信小程序折叠面板 (类似手风琴 收起展开一样的噢)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!