微信小程序--问题汇总及详解之tab切换
设置背景颜色就直接在page里设置 page {background-color: rgb(242, 242, 242);}
tab切换:
navigator 页面链接

传参的格式为url="路径?title={{item.title}}" 多个用&&连接
下个页面接收参数:

wxml:
<view class="container">
<view class="swiper-tab">
<view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">进行中</view>
<view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">已完成</view>
</view>
<swiper current="{{currentTab}}" class="swiper-box" duration="800" style="height:{{winHeight - 71}}px" bindchange="bindChange"> <!-- 朴智妍一 -->
<swiper-item>
<view class="content" wx:for="{{loadingList}}" wx:key="id" >
<navigator bindtap="bindIndexId" data-index-id="{{item.id}}" url="../..?act_name={{item.act_name}}&&pro_name={{item.pro_name}}">
<image src="{{item.act_pic}}"></image>
<view class="txt1">{{item.act_name}}</view>
<view>{{item.pro_name}}</view>
</navigator>
</view>
<view class="hb" bindtap="addProject">
<image src="../Image/addT.png" style="width:30rpx;height:30rpx;float:left;margin-top:3rpx;margin-right:16rpx;"></image>
<view class="text2">添加项目</view>
</view>
</swiper-item>
</swiper>
</view>
wxss:
page {
background-color: rgb(242, 242, 242); /*设置背景颜色就直接在page里设置*/
}
.container {
width: 100%;
}
.swiper-tab {
width: 84%;
text-align: center;
line-height: 60rpx;
margin-top: 40rpx;
margin-bottom: 20rpx;
border: 2rpx solid #1c7bf3;
border-radius: 6rpx;
}
.swiper-tab-list {
font-size: 28rpx;
display: inline-block;
width: 50%;
float: left;
color: #1c7bf3;
}
.on {
color: #fff;
background-color: #1c7bf3;
box-shadow: 0 0 20rpx #d1e5fd;
}
.swiper-box {
display: block;
height: 100%;
width: 100%;
overflow: hidden;
}
image {
width: 140rpx;
height: 140rpx;
display: inline-block;
overflow: hidden;
border-radius: 100%;
float: left;
margin-top: 36rpx;
margin-left: 26rpx;
margin-right: 30rpx;
}
.content {
width: 94%;
height: 220rpx;
box-shadow: 0 0 20rpx #bbb;
margin: auto;
margin-top: 22rpx;
line-height: 220rpx;
font-size: 32rpx;
margin-left: 3%;
background: #fff;
border-radius: 8rpx;
}
.content>view {
float: left;
}
.txt1 {
color: #ff5438;
}
.hb {
text-align: center;
margin-top:70rpx;
font-size: 28rpx;
width: 100%;
margin-left:36%;
}
.text2 {
color: #bbb;
float: left;
}
view {
display: inline-block;
}
js:
/*获取系统信息*/
wx.getSystemInfo({
success: function (res) {
that.setData({
winWidth: res.windowWidth,
winHeight: res.windowHeight
});
}
})
}, /** 滑动切换tab **/
bindChange: function (e) {
var that = this;
that.setData({ currentTab: e.detail.current }); },
/** 点击tab切换 **/
swichNav: function (e) {
var that = this;
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current
})
}
},
var app = getApp()
Page({
data: {
winWidth: 0, /* 页面配置*/
winHeight: 0,
currentTab: 0, // tab切换
oneList: [{ //遍历数组,前台需要请求遍历的参数
id: '',
act_pic:'',
act_name: '',
pro_name: '',
}],
},
//获取点击的产品ID,并保存在本地缓存 (进行中)
bindIndexId: function (e) {
var indexId = e.currentTarget.dataset.indexId
wx.setStorageSync('indexId', indexId)
},
onLoad: function () {
var that = this;
var tokend = wx.getStorageSync('tokend') //取token
//刷新页面后得到进行中的数据
wx.request({
method: 'GET',
url: 'https://....?token=' + tokend,
header: {'content-type': 'application/json'},
data: {},
success: function (res) { // success
console.log(res)
that.setData({ //将后台数值与前台数组匹配(集合)
loadingList: res.data.data
})
}
});
微信小程序--问题汇总及详解之tab切换的更多相关文章
- 微信小程序--问题汇总及详解之form表单
附上微信小程序开发文档链接:https://mp.weixin.qq.com/debug/wxadoc/dev/framework/MINA.html form表单: 当点击 <form/> ...
- 微信小程序--问题汇总及详解之图片上传和地图
地图用的是百度的地图,链接:http://lbsyun.baidu.com/index.php?title=wxjsapi/guide/getlocation 获取日期时间可以用小程序里自带的js文件 ...
- 微信小程序--问题汇总及详解之清空电话号码
wxml: <view class="btns" wx:for="{{phoneList}}" wx:key="id"> < ...
- 微信小程序--问题汇总及详解之picker 增、删
<block wx:for="{{salesList}}" wx:for-index="index" wx:key="id" wx:f ...
- 微信小程序 this和that详解及简单实例
微信小程序中,在wx.request({});方法调用成功或者失败之后,有时候会需要获取页面初始化数据data的情况,这个时候,如果使用,this.data来获取,会出现获取不到的情况,调试页面也会报 ...
- 微信小程序获取用户手机号详解
最近在做一款微信小程序,需要获取用户手机号,具体步骤如下: 流程图: 1.首先,客户端调用wx.login,回调数据了包含jscode,用于获取openid(用户唯一标识)和sessionkey(会话 ...
- 【微信小程序】支付过程详解
一.介绍 今天跟大家分享微信小程序集成支付. 二.分析 1.小程序支付API 地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-pay.html ...
- 微信小程序支付之代码详解
微信小程序自带的一套规则,类似vue语法,但是好多功能都集成在api中,给了很多初学者轮子,所以首先要熟悉这些api,忘记可照官网继续开发 这里主要说下微信小程序的支付,原理类似上篇介绍的公众网页支付 ...
- 微信小程序项目wx-store代码详解
这篇文章会很长,非常长,特别长,无敌长. 真的是挤牙膏般的项目进度,差不多是8月底有开始这个项目的想法,时至今日都1个多月了,抛去频繁的加班时间,王者时间,羽毛球时间...见缝插针的写这个项目,我竟然 ...
随机推荐
- 从asp.net到jsp:3分钟看透Jsp&Servlet
零:JSP是谁? 话说故事的开头是这样的:JSP全名为Java Server Pages,其根本是一个简化的Servlet设计:后来的详细事情有请各位自便.美女→找→谷哥 or 帅哥→找→度娘 插播: ...
- World Wind Java开发之十四——添加WMS地图服务资源(转)
数据是GIS的核心,没有数据一切无从谈起,Internet上有很多在线WMS地图服务资源,我们可以好好利用这些数据资源,比如天地图.必应地图.NASA.OGC数据服务等等. 在我们国家常用的还是天地图 ...
- hdu-2256 Problem of Precision---矩阵快速幂+数学技巧
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2256 题目大意: 题目要求的是(sqrt(2)+sqrt(3))^2n %1024向下取整的值 解题 ...
- oc语言基础整理
objc.h---------------- typedef struct objc_class *Class; struct objc_object { Class isa OBJC_ISA_AV ...
- handlebars用法
为什么需要模板引擎 关于前端的模板引擎,我用一个公式来解释 模板引擎 模板 + 数据 ========> html页面 模板引擎就像是html的解析生成器,将对应的模板填充完数据之后生成静态的h ...
- 将bat批处理文件注册成windows服务
C:\Users\lenovo>sc create MyService binPath= "C:\Program Files\restartOracle.bat" type ...
- 问题 F: 等比数列
问题 F: 等比数列 时间限制: 1 Sec 内存限制: 64 MB提交: 2699 解决: 1214[提交][状态][讨论版][命题人:外部导入] 题目描述 已知q与n,求等比数列之和: 1+q ...
- JS中进行浮点数计算式,遇到的问题
今天在做项目时,需要在页面进行计算,但是当两个数都是小数时,计算的结果却不是想象中的: 比如1371.3-0.9算出来却是1370.39999999,后来上网搜一下,原来js是弱类型语言,没有那么高的 ...
- Pots POJ - 3414 (搜索+记录路径)
Pots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22688 Accepted: 9626 Special J ...
- Spring - 什么是IOC?