小程序中tab切换页面效果如何做,代码是什么
Admin 2022-08-12 群英技术资讯 893 次浏览
本文实例为大家分享了小程序实现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, }); },
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
用JavaScript怎样做点击显示隐藏的效果?点击显示或者点击隐藏效果的应用场景有很多,例如导航菜单,图片展示等等,因此本文就给大家分享一下如何实现简单的点击显示隐藏,实现效果及代码如下:
这篇文章我们来了解用jQuery如何获取ul下li的个数,下文示例对新手学习jQuery有一定的参考价值,有这方面学习需要的朋友接下来就跟随小编来一起学习一下吧!
不通过路由的情况下, 怎么懒加载一个angular模块,并动态创建其中声明的组件?下面本篇文章给大家介绍一下方法,希望对大家有所帮助!
今天给大家分享的是使用JavaScript实现简易的alert弹框功能的内容,实现效果及代码如下,对新手学习JavaScript有一定的帮助,需要的朋友可以参考,希望大家阅读完这篇文章能有所收获,接下来我们就一起来了解看看吧。
1.使用fs复制文件使用fs对象的readFileSync,writeFileSync方法进行读写操作复制cp.jsfunctioncopyIt(from,to){fs.writeFileSync(to,fs.readFileSync(from));//fs.createReadStream(src).pipe(fs.createWriteStream(dst));
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008