微信小程序折叠面板 (类似手风琴 收起展开一样的噢)

这篇具有很好参考价值的文章主要介绍了微信小程序折叠面板 (类似手风琴 收起展开一样的噢)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

效果图微信小程序手风琴效果,微信小程序,前端,小程序微信小程序手风琴效果,微信小程序,前端,小程序

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

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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包