微信小程序?qū)崿F(xiàn)列表滾動(dòng)頭部吸頂?shù)氖纠a
本文介紹了小程序頭部吸頂?shù)膶?shí)現(xiàn)代碼示例,分享給大家,也給自己留個(gè)筆記
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; }
到此這篇關(guān)于微信小程序?qū)崿F(xiàn)列表滾動(dòng)頭部吸頂?shù)氖纠a的文章就介紹到這了,更多相關(guān)小程序列表滾動(dòng)頭部吸頂內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
利用javascript的面向?qū)ο蟮奶匦詫?shí)現(xiàn)限制試用期
Javascript是一種面向?qū)ο蟮哪_本語(yǔ)言,其也具有面向?qū)ο蟮娜筇匦?,但是今天我們不詳?xì)的講解javascript的面向?qū)ο筇匦裕裉煳覀兒?jiǎn)單的了解一下javascript的面向?qū)ο筇匦裕缓髮W(xué)習(xí)一下怎樣實(shí)現(xiàn)試用期的限制!2011-08-08js獲取UserControl內(nèi)容為拼html時(shí)提供方便
js獲取UserControl內(nèi)容時(shí)無(wú)法測(cè)試通過(guò),原來(lái)是繼承了Page 然后使用VerifyRenderingInServerForm驗(yàn)證2014-11-11javascript實(shí)現(xiàn)的字符串與十六進(jìn)制表示字符串相互轉(zhuǎn)換方法
這篇文章主要介紹了javascript實(shí)現(xiàn)的字符串與十六進(jìn)制表示字符串相互轉(zhuǎn)換方法,涉及javascript字符串轉(zhuǎn)換的相關(guān)技巧,在防止SQL注入和XSS中具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-07-07禁用Enter鍵表單自動(dòng)提交實(shí)現(xiàn)代碼
這篇文章主要介紹了禁用Enter鍵表單自動(dòng)提交實(shí)現(xiàn)代碼,需要的朋友可以參考下2014-05-05利用JavaScript實(shí)現(xiàn)防抖節(jié)流函數(shù)的示例代碼
在開(kāi)發(fā)中我們經(jīng)常會(huì)遇到一些高頻操作,比如:鼠標(biāo)移動(dòng),滑動(dòng)窗口,鍵盤(pán)輸入等等,節(jié)流和防抖就是對(duì)此類(lèi)事件進(jìn)行優(yōu)化,降低觸發(fā)的頻率,以達(dá)到提高性能的目的。本文就教大家如何實(shí)現(xiàn)一個(gè)讓面試官拍大腿的防抖節(jié)流函數(shù),需要的可以參考一下2022-08-08JavaScript編寫(xiě)帶旋轉(zhuǎn)+線條干擾的驗(yàn)證碼腳本實(shí)例
除了普通的可點(diǎn)擊更換的四位驗(yàn)證碼實(shí)現(xiàn),我們這里還展示了更進(jìn)一步的JavaScript編寫(xiě)帶旋轉(zhuǎn)+線條干擾的驗(yàn)證碼腳本實(shí)例,需要的朋友可以參考下2016-05-05