小程序tab切换 点击左右滑动
wxml
<scroll-view scroll-x="true" class="navbar-box">
<block wx:for="{{recordMain}}" wx:for-index="idx" wx:for-item="navItem" wx:key="idx">
<view class="nav-item " data-current="{{idx}}" bindtap="switchNav">
<text class="{{currentTab == idx ? 'active' : ''}}">{{navItem.title}}</text>
</view>
</block>
</scroll-view> <swiper style="margin-top:80rpx;height:{{winHeight - 40}}px;" class="tab-box" current="{{currentTab}}" duration="" data-current="{{idx}}" bindchange="switchTab">
<swiper-item style="height:100%;overflow-y:scroll" wx:for="{{[0,1,2,3,4,5]}}" wx:for-item="tabItem" wx:for-index="idx" wx:key="idx" class="tab-cnetent">
<block wx:for="{{tabContent}}" wx:key=" " bindtap='myOrderDetails'>
<!-- 列表 -->
<view class='listBox'>
<view class='listTop'>
<image src='{{item.goodsImg}}' class='goodsImg'></image>
<view class='infor'>
<view class=''>
<text class='name'>{{item.name}}</text>
<text class='price'>¥{{item.price}}</text>
</view>
<view class=''>
<text class='choose'>{{item.choose}}</text>
<text class='number'>×{{item.number}}</text>
</view>
</view>
</view>
<view class='listBottom'>
<view>共{{item.number}}件商品,合计:¥{{item.allPrice}}</view>
<view class='status'>
<button>查看物流</button>
<button>确认收货</button>
</view>
</view>
</view>
</block>
</swiper-item>
</swiper>
wxss
::-webkit-scrollbar {
width: ;
height: ;
color: transparent;
}
.navbar-box {
height: 70rpx;
line-height: 70rpx;
position: fixed;
top: 0rpx;
background: white
}
.nav-item {
display: inline-block;
width: 16.6%;
text-align: center;
}
.nav-item text {
padding-bottom: 10rpx;
}
page {
background: #f2f2f2;
font-size: 28rpx;
}
.active {
color: #a53533;
border-bottom: 4rpx solid #a53533;
box-sizing: border-box;
}
.menu {
font-size: 28rpx;
width: %;
/* overflow-x: scroll; */
border-bottom: 20rpx solid #f2f2f2;
padding: 30rpx 30rpx 0rpx 30rpx;
box-sizing: border-box;
display: flex;
justify-content: space-between;
position: fixed;
top: 0rpx;
z-index: ;
background: white;
}
.chooseNav {
padding-bottom: 10rpx;
}
.listBox {
padding: 30rpx;
width: calc(% - 60rpx);
margin-left: 30rpx;
margin-top: 30rpx;
background: white;
box-sizing: border-box;
border-radius: 8rpx;
}
.listTop {
display: flex;
justify-content: space-between;
}
.goodsImg {
width: 200rpx;
height: 200rpx;
margin-right: 20rpx;
}
.infor {
flex: ;
margin-top: 80rpx;
font-size: 26rpx;
color: #;
}
.infor view {
width: %;
display: flex;
justify-content: space-between;
}
.infor view:nth-of-type() {
font-size: 24rpx;
}
.name, .choose {
font-weight: ;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
width: 320rpx;
}
.price, .number {
padding: 5rpx 10rpx;
box-sizing: border-box;
}
.listBottom {
text-align: right;
}
button::after {
border: none;
}
.status button {
display: inline-block;
background: white;
border: 1px solid #dedede;
border-radius: 66rpx;
font-size: 24rpx;
margin-left: 20rpx;
color: #;
padding: 0rpx 30rpx;
box-sizing: border-box;
height: 50rpx;
line-height: 45rpx;
margin-top: 20rpx;
}
wxjs
Page({
data: {
recordMain: [
{
title: "全部"
},
{
title: "待付款"
},
{
title: "待发货"
},
{
title: "待发货"
}, {
title: "已完成"
},
{
title: "已取消"
},
],
tabContent: [
{
goodsImg: '/img/goods.png',
name: '阿莎玛沙阿莎玛沙发阿莎玛沙发阿莎玛沙发阿莎玛沙莎玛沙发发',
price: "",
choose: '已选:全新,16期',
number: '',
allPrice: ''
},
],
currentTab: ,
navScrollLeft: ,
winWidth: ,
winHeight: ,
},
// 事件处理函数
onLoad: function () {
var that = this;
/** 获取系统信息*/
wx.getSystemInfo({
success: function (res) {
that.setData({
winWidth: res.windowWidth,
winHeight: res.windowHeight,
});
}
});
},
// 滑动事件
// 点击标题切换当前页时改变样式
switchNav:function(e) {
console.log(e.currentTarget.dataset.current)
var that = this
var cur = e.currentTarget.dataset.current;
if (that.data.currentTab == cur) {
return false;
} else {
that.setData({
currentTab: cur
})
}
},
// 滚动切换标签样式
switchTab: function(e) {
console.log(e)
var that = this;
that.setData({
currentTab: e.detail.current
});
if (e.detail.current == ) {
console.log()
}
else if (e.detail.current == ) {
console.log()
}
else if (e.detail.current == ) {
console.log()
}
else if (e.detail.current == ) {
console.log()
}
else if (e.detail.current == ) {
console.log()
}
else if (e.detail.current == ) {
console.log()
}
}
})

小程序tab切换 点击左右滑动的更多相关文章
- 微信小程序tab切换,可滑动切换,导航栏跟随滚动实现
简介 看到今日头条小程序页面可以滑动切换,而且tab导航条也会跟着滚动,点击tab导航,页面滑动,切导航栏也会跟着滚动,就想着要怎么实现这个功能 像商城类商品类目如果做成左右滑动切换类目用户体验应该会 ...
- 根据id来实现小程序tab切换,
本例根据绑定id来实现tab切换,但本例仍有缺陷,用for循环数据,无法实现切换.如有大神能够有更好方法,欢迎留言更正 WXML: <view class="tab"> ...
- 小程序——Tab切换
<view class="body"> <view class="nav bc_white"> <view class=" ...
- 小程序tab切换代码
<!--index.wxml--> <view class="container"> <view class="navtap" & ...
- 微信小程序Tab选项卡切换大集合
代码地址如下:http://www.demodashi.com/demo/14028.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...
- 小程序TAB列表切换内容动态变化,scrollview高度根据内容动态获取
滑动tab选项卡 一.在小程序里面tab选项卡是用的是自带的swiper组件,下面直接上代码 <view class="container"> <view cla ...
- 微信小程序关于tabbar点击切换数据不刷新问题
微信小程序中经常遇到的需求就是我提交了一个表单或者进行了一个操作,需要在我的个人中心页面中实时显示出来,但是小程序中的tabbar切换类似于tab切换 并不会进行页面刷新请求 所以总是会造成一些数据更 ...
- 微信小程序tab(swiper)切换
<- wxml -> <view class="youhui"> <view ' bindtap='toggle'> 未使用 </view ...
- 微信小程序-tab标签栏实现教程
一.摘要 tab栏(标签切换栏)是app中常见的一种交互方式,它可以承载更多的内容,同时又兼顾友好体验的优点.但在小程序中,官方并没有为咱们提供现成的组件.因此我们程序员展现才艺的时候到了(其实市面上 ...
随机推荐
- Python练习--普通函数与递归函数求阶乘
'''Created on 2018年10月28日递归函数示例:阶乘'''def my_fun_example1(n): ''' 非递归函数求阶乘示例 ''' result = ...
- 《高性能Mysql》解读---Mysql的事务和多版本并发
1.base:ACID属性,并发控制 2.MySql事务的隔离级别有哪些,含义是什么? 3.锁知多少,读锁,写锁,排他锁,共享锁,间隙锁,乐观锁,悲观锁. 4.Mysql的事务与锁有什么关联?MySq ...
- android 开发设计模式---观察者模式
情景1 有一种短信服务,比如天气预报服务,一旦你订阅该服务,你只需按月付费,付完费后,每天一旦有天气信息更新,它就会及时向你发送最新的天气信息. 情景2 杂志的订阅,你只需向邮局订阅杂志,缴纳一定的费 ...
- Mysql 版本号、存储引擎、索引查询
[1]Mysql 版本号.存储引擎.索引查询 # 查看数据库版本号 SELECT VERSION(); # 查看数据库支持的引擎(默认即Support == DEFAULT行) SHOW ENGINE ...
- sql 与 mysql
my sql 中=和!=运算符是不起作用的:
- CCF CSP 201512-1 数位之和
题目链接:http://118.190.20.162/view.page?gpid=T37 问题描述 试题编号: 201512-1 试题名称: 数位之和 时间限制: 1.0s 内存限制: 256.0M ...
- CCF CSP 201509-1 数列分段
题目链接:http://118.190.20.162/view.page?gpid=T32 问题描述 试题编号: 201509-1 试题名称: 数列分段 时间限制: 1.0s 内存限制: 256.0M ...
- [ABP] ASP.NET Zero 5.6.0 之 ASP.NET Zero Power Tools 破解日志
两个要破解Patch的关键dll名称:AspNetZeroRadToolVisualStudioExtension.dll和AspNetZeroRadTool.dll AspNetZeroRadToo ...
- Linux常用的基础命令总结
man 查看英文命令帮助 可以看作--help 拷贝目录的命令cp -a 包含所有 ls -a 显示所有文件包括隐藏文件 -ld ls -F 过滤目录文件(给不同类型文件结尾加上不同的符号) ...
- laravel中ajax,post传值问题
//laravel中有CSRF保护 不加的话会出现419错误$.ajax({ url: '/admin/user/'+id, type: "POST", data: {'_toke ...