小程序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中常见的一种交互方式,它可以承载更多的内容,同时又兼顾友好体验的优点.但在小程序中,官方并没有为咱们提供现成的组件.因此我们程序员展现才艺的时候到了(其实市面上 ...
随机推荐
- if语句&switch&Scanner
if流程控制语句: if 语句的用语法如下: if(boolean表达式){ //如果条件为true那么执行 } 只有条件为true时才会执行,否则执行if语句后面的代码. 实例代码: public ...
- 从Redis中删除大集合对象的方法
Redis中的大集合对象,如set.zset等,如果有上千万个元素,一般是不能直接用del命令来删除的,因为del命令可能会耗时几秒钟,而redis本身是单线程的,在高并发的情况下会阻塞大量的请求,严 ...
- 煎蛋ooxx
pipeline.py class Jiandanline(FilesPipeline): def get_media_requests(self, item, info): for file_url ...
- GO值类型与引用类型
值类型 值类型包括基本数据类型,int,float,bool,string,以及数组和结构体(struct). 值类型变量声明后,不管是否已经赋值,编译器为其分配内存,此时该值存储于栈上. 值类型的默 ...
- LINUX 编程定位工具gstack,pstack
pstack: pstack命令可显示每个进程的栈跟踪. pstack 命令必须由相应进程的属主或 root 运行. 可以使用 pstack 来确定进程挂起的位置. 此命令允许使用的唯一选项是要检查的 ...
- 爬坑二 activiti流数据库版本错误引发的问题
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actModelCont ...
- Numpy 和 Matplotlib库的学习笔记
Numpy介绍 一个用python实现的科学计算,包括:1.一个强大的N维数组对象Array:2.比较成熟的(广播)函数库:3.用于整合C/C++和Fortran代码的工具包:4.实用的线性代数.傅里 ...
- B/S架构图解
- psql 存储过程
--添加人员和虹膜注册信息 CREATE OR REPLACE FUNCTION AddPersonInfoAndIrisEnrollInfo(personName character, workSn ...
- python实现简单算法
#选择n^2def selectSort(li): for i in range(len(li)-1): minLoc = i for j in range(i+1,len(li)): if li[j ...