时间:2021-05-18
本文介绍了小程序头部吸顶的实现代码示例,分享给大家,也给自己留个笔记
demo 地址: https://github.com/iotjin/Jh_weapp
效果图:
吸顶主要是 position: sticky;
.header { background: rgb(230, 230, 230); height: 25px; line-height: 25px; padding-left: 30rpx; font-size: 13px; align-items: center; position: sticky; top: 0;}js 代码:
Page({ data: { dataArr: [{ "AB_MonthDay": "30/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭1", "AB_Money": "11", "AB_Remark": "备注", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", },{ "AB_LeiBie": "吃饭1", "AB_Money": "22", "AB_Remark": "备注2", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", },{ "AB_LeiBie": "红包1", "AB_Money": "33", "AB_Remark": "备注33", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "收入", }, ] }, { "AB_MonthDay": "29/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭2", "AB_Money": "22", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "28/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭3", "AB_Money": "33", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "27/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭4", "AB_Money": "44", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "26/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭4", "AB_Money": "44", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "25/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭4", "AB_Money": "44", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "24/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭4", "AB_Money": "44", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "23/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭4", "AB_Money": "44", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "22/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭4", "AB_Money": "44", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "21/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭4", "AB_Money": "44", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "20/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭4", "AB_Money": "44", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, { "AB_MonthDay": "19/06", "AB_ZhiChu": "1111", "AB_ShouRu": "2222", "AB_Bill": [{ "AB_LeiBie": "吃饭4", "AB_Money": "44", "AB_Remark": "", "AB_Date": "2011-11-11 15:38:16", "AB_FenLei": "支出", }] }, ] }, onShow: function () { }, onPageScroll: function (res) { console.log(res.scrollTop); }})wxml 代码:
<view class="main-bg"> <view wx:for="{{dataArr}}" wx:key="index" class="section"> <view class="header"> {{item.AB_MonthDay}}</view> <view wx:for="{{item.AB_Bill}}" wx:key="index" class="cell"> <view class="row1"> <view wx:if="{{item.AB_Remark}}" class="leibie">{{item.AB_LeiBie}} · {{item.AB_Remark}}</view> <view wx:else="{{!item.AB_Remark}}" class="leibie">{{item.AB_LeiBie}}</view> <view class='{{item.AB_FenLei=="收入"?"money2":"money"}}'>{{item.AB_Money}}</view> </view> </view> </view></view>wxss 代码:
.header { background: rgb(230, 230, 230); height: 25px; line-height: 25px; padding-left: 30rpx; font-size: 13px; align-items: center; position: sticky; top: 0;}.cell { background: white; height: 44px; align-items: center; line-height: 44px; border-bottom: 1px solid rgb(230, 230, 230);}.row1 { margin-left: 30rpx; display: flex; justify-content: space-between;}.leibie { width: 70%; font-size: 30rpx; color: black; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;}.money { font-size: 32rpx; color: black; font-weight: bold; margin-right: 30rpx;}.money2 { font-size: 32rpx; color: #38BC9D; font-weight: bold; margin-right: 30rpx;}到此这篇关于微信小程序实现列表滚动头部吸顶的示例代码的文章就介绍到这了,更多相关小程序列表滚动头部吸顶内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例为大家分享了微信小程序实现无限滚动列表的具体代码,供大家参考,具体内容如下效果图1.0实现方式是利用小程序原声组件swiper,方向设置为纵向:vert
本文实例为大家分享了小程序实现吸顶功能的具体代码,供大家参考,具体内容如下//如图所示----这里用了自定义组件实现了小程序吸顶功能//WXML第一层{{ite
微信小程序开发之好友列表字母列表跳转对应位置前言:在小程序里实现微信好友列表点击右侧字母列表跳转对应位置效果。写了个demo,核心部分很简单,所以没多少注释,如
我们在微信小程序中经常会使用到分享商品海报,或者是重绘微信小程序分享链的图片功能。实现该功能只要跟着如下几个步骤就可以快速实现啦!(本文示例代码使用的是uni-
小程序APP如何快速运营盈利,实现转化小程序则背靠微信巨大流量,目前已开发附近小程序、主动搜索小程序,微信好友聊天和微信群扫码识别,公众号菜单关联、聊天列表置顶