小程序实现tab更换页面效果
作者:小雅雅家的小凯凯吖 时间:2024-04-16 09:32:28
本文实例为大家分享了小程序实现tab更换页面效果的具体代码,供大家参考,具体内容如下
.wxml
<scroll-view scroll-x="true" class="ip_tab_comtainer">
<view class="ip_tab_comtainer_padd"></view>
<block wx:for="{{ips}}" wx:for-item="ip" wx:key="{{ip.id}}">
<view class="{{ip.isSelect?'ip_tab_item_s':'ip_tab_item_n'}}" bindtap="onIpItemClick" wx:key="" data-item="{{ip}}">
{{ip.title}}
</view>
</block>
<view class="ip_tab_comtainer_padd"></view>
</scroll-view>
<view class='content'>
<block>
<view class="content1" wx:if="{{content=='日统计'}}">{{content}}</view>
<view class="content2" wx:if="{{content=='月统计'}}">{{content}}</view>
<view class="content3" wx:if="{{content=='年统计'}}">{{content}}</view>
</block>
</view>
.wxss
page{
width: 100%;
height: 100%;
}
.ip_tab_comtainer {
width: 100%;
background-color: #F5F5F5;
padding: 20rpx 0 0;
white-space: nowrap;
}
.ip_tab_comtainer_padd {
display: inline-block;
width: 5%;
}
.ip_tab_item_s {
width: 30%;
display: inline-block;
line-height: 40rpx;
text-align: center;
color: #91daf9;
font-size: 28rpx;
overflow: hidden;
background-color: #ffffff;
border: 1px solid #91daf9;
}
.ip_tab_item_n {
width: 30%;
display: inline-block;
text-align: center;
line-height: 40rpx;
color: #353535;
background-color: #ffffff;
font-size: 28rpx;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
border-radius: 4rpx;
border: 1px solid #CCCCCC;
}
/**
去除横向滚动条
*/
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
.content{
width: 100%;
height: 100%;
display: flex;
background-color: #CCCCCC;
}
.content1{
width: 100%;
height: 100%;
display: flex;
background-color: #6b10e0;
}
.content2{
width: 100%;
height: 100%;
display: flex;
background-color: #d41515;
}
.content3{
width: 100%;
height: 100%;
display: flex;
background-color: #1ac729;
}
.js
/**
* 页面的初始数据
*/
data: {
ips: [
{ id: "1", title: "日统计", isSelect:true },
{ id: "2", title: "月统计", isSelect: false},
{ id: "3", title: "年统计", isSelect: false},
],
content: "日统计"
},
/**
* item点击事件
*/
onIpItemClick: function (event) {
console.log(event);
var id = event.currentTarget.dataset.item.id;
var curIndex = 0;
for (var i = 0; i < this.data.ips.length; i++) {
if (id == this.data.ips[i].id) {
this.data.ips[i].isSelect = true;
curIndex = i;
} else {
this.data.ips[i].isSelect = false;
}
}
this.setData({
content: this.data.ips[curIndex].title,
ips: this.data.ips,
});
},
来源:https://blog.csdn.net/w_s_x_b/article/details/108382446
标签:小程序,tab,更换


猜你喜欢
基于ASP的站内多值搜索
2010-05-11 20:03:00
学习ASP.NET八天入门:第六天
2007-08-07 13:48:00

从源码解析Python的Flask框架中request对象的用法
2021-02-20 02:15:57
教你安装python Django(图文)
2023-11-13 14:22:39

Python对小数进行除法运算的正确方法示例
2021-06-19 08:42:18
解析xml字符串的函数
2008-06-10 12:37:00
操作Windows注册表的简单的Python程序制作教程
2023-01-04 00:17:40
Python实现约瑟夫环问题的方法
2021-09-07 19:41:28
微信公众平台开发教程⑤ 微信扫码支付模式介绍
2023-11-14 10:40:10

python列表的切片与复制示例分析
2023-07-15 02:12:34
Linux 下 Python 实现按任意键退出的实现方法
2022-08-07 14:22:01
Python 实现数据结构-循环队列的操作方法
2022-10-13 23:15:00
22个国外的Web在线编辑器收集
2023-10-09 18:09:59

1分钟快速生成用于网页内容提取的xslt
2021-08-06 17:43:41

python自定义类并使用的方法
2022-08-16 14:36:29
FckEditor配置手册中文教程详细说明
2010-02-28 12:37:00
vue-admin-element项目突然就起不来了的解决
2023-07-02 16:37:58
Python Scrapy图片爬取原理及代码实例
2022-04-29 05:51:06
Python制作简易计算器功能
2023-05-06 19:53:47

Python爬虫基础初探selenium
2023-07-26 17:40:50
