小程序动态class_微信小程序动态切换栏

54eeea1c5d6c044c13ec4c00651d3ad5.png效果展示 f775276b22cda3769501b8a3d967ff86.png

b0470a3e88cf06477c2cc677ad82d72b.gif

54eeea1c5d6c044c13ec4c00651d3ad5.pngDemo代码 f775276b22cda3769501b8a3d967ff86.png wxml
<view class='list-top'>  <ul>    <li class="{{flag==0?'active':''}}" catchtap="changeflag" data-index="0">打卡记录li>    <li class="{{flag==1?'active':''}}" catchtap="changeflag" data-index="1">月排行榜li>    <li class="{{flag==2?'active':''}}" catchtap="changeflag" data-index="2">总排行榜li>  ul>view><swiper class='swiper-1' current="{{flag}}" indicator-dots="{{swiper.indicatorDots}}" autoplay="{{swiper.autoplay}}" interval="{{swiper.interval}}" duration="{{swiper.duration}}" bindchange="changeSlider">  <block>        <swiper-item>    <image src="https://wx1.sinaimg.cn/large/691bee7aly1gbr3vrg2ceg20m80gok5e.gif">image>    swiper-item>    <swiper-item>     <image src="https://wx1.sinaimg.cn/large/691bee7aly1gbr3vsnljog20m80gogul.gif">image>    swiper-item>    <swiper-item>     <image src="https://wx1.sinaimg.cn/large/691bee7aly1gbr3vp6f91g20m80gok11.gif">image>    swiper-item>  block>swiper>  
wxss
page{  height: 100%;}/* 切换栏 */.list-top {  height: 106rpx;  box-sizing: border-box;  padding: 5px 10px;}.list-top ul {  display: flex;  height: 72rpx;  border-radius: 12rpx;}.list-top li {  flex: 1;  display: flex;  font-size: 14px;  justify-content: center;  align-items: center;  color: #FFA500;}.list-top .active {  border-radius: 50px;  border-bottom: 2px #FFA500 solid;  background: #FFA500;  color: #ffffff;}.scroll-view {  width: 100%;  white-space: nowrap;  /* 规定段落中的文本不进行换行 */}.scroll-1 {  height: 100%;}.swiper-1 {  height: 80%;}
js
//index.js//获取应用实例const app = getApp()Page({  data: {    flag: 0, //状态栏切换    swiper: {      indicatorDots: false,      autoplay: false,      interval: 5000,      duration: 1000    }, //swiper设置  },  onLoad: function () {      },  changeflag: function (e) {    var k = this    k.setData({      flag: e.target.dataset.index    })    console.log(e.target.dataset.index)  },  changeSlider: function (e) {    var k = this    this.setData({      flag: e.detail.current    })    console.log(e.detail.current)  },})
54eeea1c5d6c044c13ec4c00651d3ad5.png福利 f775276b22cda3769501b8a3d967ff86.png

?

5ddf58827c3ec28f5007e712a042241b.gif

「写留言|查看留言」

49f1bfdaaec870f80ae32bac1ba8881b.gif仙女都在看点点点,赞和在看都在这儿! 35b33581530fbf3dd497bc78ea424513.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值