微信小程序 选项卡 swiper默认高度150px(让高度实现自适应)解决方法

微信小程序并没有tab选项卡,但是有一个swiper,所以用swiper写了一个选项卡,写完之后存在一个问题,swiper的默认高度为150px,不能通过给他auto或者百分百自适应,所以经过查阅,用js实现了想要的效果。
wxml
<view class = "tab">
    <view bindtap = "titleClick" class="{
   {0 == currentIndex ? 'active' : ''}}"  data-idx='0'>全部</view>
    <view bindtap = "titleClick" class="{
   {1 == currentIndex ? 'active' : ''}}"  data-idx='1'>一级报警</view>
    <view bindtap = "titleClick" class="{
   {2 == currentIndex ? 'active' : ''}}"  data-idx='2'>二级报警</view>
  </view>
  <swiper style='height:{
   {widHeight}}' bindchange='pagechange' current='{
   {currentIndex}}'>
    <swiper-item>
      <view class = "list">
        <view class = "one oneAll" wx:for = "{
   {all}}" wx:key = "index">
        <!-- 使用 wx:for-item 可以指定数组当前元素的变量名,使用 wx:for-index 可以指定数组当前下标的变量名: 否则默认为index和item-->
          <view class = "left">
            <view class = "personal">
              <image class = "photo" src = "../../images/mine/icon-test.png"></image>
              <view class = "desc">
                <view class = "name">
                  <text class = "mz">{
   {
   item.name}}</text>
                  <text class = "age">{
   {
   item.age}}</text>
                </view>
                <text class = "address">{
   {
   item.address}}</text>
                <view class = "state">
                  <image src = "../../images/mine/xingxing.png"></image>
                  <text class = "both">检测状态:</text>
                  <text class = "normal">{
   {
   item.state}}</text>
                </view>
              </view>
            </view>
          </view>
          <view class = "right">
            <image src = "../../images/mine/qianjin.png"></image>
          </view>
        </view>
      </view>
    </swiper-item>
    <swiper-item>
      <view class = "list">
        <view class = "one" wx:for = "{
   {one}}" wx:for-item = "oneItem" wx:key = "index">
          
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值