1.wxml页面

<!--index.wxml-->
<swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:362rpx" bindchange="bindChange"> <!-- 我是哈哈 -->
<swiper-item>
<view class="page__bd">
<view class="weui-grids">
<block wx:for-items="{{grids}}" wx:key="{{index}}">
<view class="weui-grid" hover-class="weui-grid_active" data-index="{{index}}" data-id="{{0}}" bindtap="click">
<image class="weui-grid__icon" src="../../images/icon_tabbar.png" />
<view class="weui-grid__label">{{'哈哈-' + index}}</view>
</view>
</block>
</view>
</view>
</swiper-item> <!-- 我是呵呵 -->
<swiper-item>
<view class="page__bd">
<view class="weui-grids">
<block wx:for-items="{{grids}}" wx:key="{{index}}">
<view class="weui-grid" hover-class="weui-grid_active" data-index="{{index}}" data-id="{{1}}" bindtap="click">
<image class="weui-grid__icon" src="../../images/icon_tabbar.png" />
<view class="weui-grid__label">{{'呵呵-' + index}}</view>
</view>
</block>
</view>
</view>
</swiper-item> </swiper> <view class="indicator">
<block wx:for="{{swiperList}}">
<view class="swiper_item" style="background-color:{{index == currentTab?'#04b00f':'#aaaaaa'}};"></view>
</block>
</view>

2.js页面

//获取应用实例
var app = getApp() Page({
data: {
currentTab: 0,
grids: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
swiperList:[0, 1, 2, 3, 4]
},
onLoad: function () {
},
click: function (e) {
console.log(e.currentTarget.dataset.id)
console.log(e.currentTarget.dataset.index)
wx.showToast({
title: '第' + e.currentTarget.dataset.id + '栏' + '第' + e.currentTarget.dataset.index + '个',
icon: 'success',
duration: 1500
})
},
/**
* 滑动切换tab
*/
bindChange: function (e) {
console.log(e.detail.current)
this.setData({ currentTab: e.detail.current });
},
})

3.样式wxss页面

/**index.wxss**/

.swiper-box {
display: block;
height: 100%;
width: 100%;
overflow: hidden;
} .swiper-box view {
text-align: center;
} .weui-grids {
border-top: 1rpx solid #d9d9d9;
border-left: 1rpx solid #d9d9d9;
overflow: hidden;
} .weui-grid {
position: relative;
float: left;
padding: 20px 10px;
width: 20%;
box-sizing: border-box;
/*border-right: 1rpx solid #D9D9D9;
border-bottom: 1rpx solid #D9D9D9;*/
} .weui-grid__icon {
display: block;
width: 28px;
height: 28px;
margin: 0 auto;
} .weui-grid__label {
margin-top: 5px;
display: block;
text-align: center;
color: #000;
font-size: 14px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
} .indicator {
width: 100%;
height: 60rpx;
display:flex;
flex-direction:row;
justify-content:center;
align-items:center;
background: #eee;
} .swiper_item {
margin: 15rpx 10rpx;
position: relative;
float: left;
width: 30rpx;
height: 30rpx;
border-radius: 50%;
background-color: #aaa;
}

最新文章

  1. [原]CentOS7部署PostGis
  2. Linux下安装流量监控工具iftop
  3. asp.net 使用DroDownList来实现二级联动
  4. iOS开发笔记1:[转]导航栏里的&quot;Back&quot;按钮显示不出来
  5. Android总结篇系列:Android Service
  6. graph | hungary
  7. jQuery源码的几篇文章
  8. Google Chrome七大新特性
  9. UNIX环境高级编程-环境配置
  10. [原创]谷歌插件 - YE启动助手(YeLauncher)
  11. (转载)c库不正确问题
  12. 数据库性能高校:CPU使用过高(下)
  13. 用命令行方式关闭linux防火墙
  14. 为实体类增加toJSON方法
  15. activemq修改端口
  16. Egret里用矢量挖圆形的洞
  17. Linux下solr集群搭建
  18. IIC总线初识
  19. php里input数组的应用
  20. i春秋CTF web题(1)

热门文章

  1. 一、threejs————灯光阴影
  2. BloodHound可视化之域分析
  3. SSM使用AbstractRoutingDataSource后究竟如何解决跨库事务
  4. switch 语句 总结笔记
  5. python里奇怪的赋值
  6. css3神奇的圆角边框、阴影框及其图片边框
  7. antd-design
  8. Fiddler: AutoResponder 构建模拟测试场景
  9. java流程控制结构
  10. Pandas 中对列 groupby 后进行 sum() 与 count() 区别及 agg() 的使用方法