【微信小程序】swiper滑动页面,滑块左右各露出前后的一部分,露出一部分

在这里插入图片描述

<!--pages/vip/vip.wxml-->
<view class="pageBox">
  <swiper class="swiper" current="{{currentTab}}" next-margin="50rpx" previous-margin="50rpx" bindchange="switchTab" style="width: 100%;height:400rpx;position: absolute;top:{{40*2}}rpx;left: 0;z-index: 999;">
    <block wx:for="{{4}}" wx:key="index">
      <swiper-item item-id="{{index}}" data-item-id="{{index}}" bindtap='clickChange'>
        <view class='li'>
          <image class="vipImg" src="/image/vip{{index}}.png"></image>
        </view>
      </swiper-item>
    </block>
  </swiper>
  <swiper class="tab-content" current="{{currentTab}}" duration="300" bindchange="switchTab">
    <swiper-item wx:for="{{4}}" wx:key="index">
      <scroll-view scroll-y="true" class="scoll-h">
        <image class="bgImg" src="/image/vip{{index}}Bg.png" show-menu-by-longpress></image>
      </scroll-view>
    </swiper-item>
  </swiper>
</view>
/* pages/vip/vip.wxss */
page {
  width: 100%;
  height: 100%;
  display: flex;
  overflow: hidden;
  background-color: #1a1728;
}

.pageBox { 
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #1a1728;

}
    

 
.vipImg {
  width: 95%;
  height: 90%;
  position: relative;
}

.vipImg:nth-child(4) {
  width: 120%;
  height: 90%;
  position: relative;
}
  
.tab-content,
.bgImg {
  width: 100%;
  height: 100%;
}

.scoll-h {
  height: 100%;
}

.scrollBox {
  /* background-color: pink; */
  height: 380rpx;
  display: flex;
  flex-wrap: nowrap;
  width: 400%;
}

.vipCurrImg {
  position: absolute;
  top: 25%;
  left: 48%;
  width: 104rpx;
  height: 40rpx;
}
 
.li {
  width: 100%;
  height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
}
 
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {  
    currentTab: 0, //预设当前项的值
  }, 
 
  // 滚动切换标签样式
  switchTab: function (e) {
    console.log('swiper', this.data.currentTab);
    console.log('swiper', e.detail.current);
    this.setData({
      currentTab: e.detail.current,
    });
    console.log(e.detail.current);
    // this.checkCor();
  },

 

 
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值