微信小程序使用swiper实现侧滑功能
2017-10-22 13:31
891 查看
在很多的框架中,都有一个侧滑的组件,命名基本都是叫toolbar之类的,而且他的功能也是基本类似,
使用swiper的话,可以实现它的侧滑功能,具体实现如下:
2017-12-08补:新写了一篇不使用控制自动滚动的代码传送门
希望大家能有自己的见解。所以我就不讲述自己的思路,有兴趣的情扣1738731967
使用swiper的话,可以实现它的侧滑功能,具体实现如下:
<view>点击下方文字切换</view><view bindtap='view1' class='bluechose'>蓝色</view><view bindtap='view2' class="greenchose">绿色</view><swiper autoplay='{{isauto}}' duration='100' interval="100" bindchange='getswiper'> <swiper-item> <view style="background:#0000ff;height:150px;"></view> </swiper-item> <swiper-item> <view style="background:#00ff00;height:150px;"></view> </swiper-item></swiper> <view>点击下方文字切换</view> <view bindtap='view1' class='bluechose'>蓝色</view> <view bindtap='view2' class="greenchose">绿色</view> <swiper autoplay='{{isauto}}' duration='100' interval="100" bindchange='getswiper'> <swiper-item> <view style="background:#0000ff;height:150px;"></view> </swiper-item> <swiper-item> 查找 无结果 /pages/index/index.wxml
Page({ data: { nowcurrentindex: 0, isauto: false, }, getswiper: function (e) { console.log(e.detail.current); this.data.nowcurrentindex = e.detail.current; }, view1: function () { var _this = this; if (this.data.nowcurrentindex == 0) { return false; } this.data.isauto = true; this.setData(this.data); setTimeout(function () { _this.data.isauto = !_this.data.isauto; _this.setData(_this.data); console.log(_this.data.isauto); }, 150); }, view2: function () { var _this = this; if (this.data.nowcurrentindex == 1) { return false; } var _this = this; this.data.isauto = true; this.setData(this.data); setTimeout(function () { _this.data.isauto = !_this.data.isauto; _this.setData(_this.data); console.log(_this.data.isauto); }, 150); }, })
2017-12-08补:新写了一篇不使用控制自动滚动的代码传送门
希望大家能有自己的见解。所以我就不讲述自己的思路,有兴趣的情扣1738731967
相关文章推荐
- 原创:微信小程序+WEB使用JS实现注册【60s】倒计时功能
- 使用node.js实现微信小程序实时聊天功能
- 微信小程序注册60s倒计时功能 使用JS实现注册60s倒计时功能
- 微信小程序使用progress组件实现显示进度功能【附源码下载】
- 使用DeviceOne实现微信小程序功能
- 微信小程使用swiper组件实现图片轮播切换显示功能【附源码下载】
- 微信小程序:使用swiper与scroll-view实现tab选项卡(2)
- 微信小程序例子——使用swiper组件实现图片切换
- 微信小程序使用input组件实现密码框功能【附源码下载】
- 微信小程序使用swiper组件实现类3D轮播图
- 使用微信小程序自定义组件实现的tabs选项卡功能
- 微信小程序中使用ECharts 异步加载数据实现图表功能
- 微信小程序--使用swiper实现滚动广告
- 微信小程序实现快递查询功能(界面传值、JSON数据请求和解析、radio-group的使用...)
- 使用wxapp-img-loader自定义组件实现微信小程序图片预加载功能
- 微信小程序使用picker实现时间和日期选择框功能【附源码下载】
- Android程序:使用SeekBar实现滑动进度条功能
- C#开发微信门户及应用(28)--微信“摇一摇·周边”功能的使用和接口的实现