本文實例為大家分享了微信小程序實現吸頂盒效果的具體代碼微信小程序設置滾動條,供大家參考,具體內容如下
html部分
? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?合伙人 ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ?操作 ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? {{item.agent_name}} ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
成員管理 ? ? ? ? ? ? ? ? ? ? ? ?設備管理 ? ? ? ? ? ? ? ? ? ? ? ?門店管理 ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?補貨申請 ? ? ? ? ? ? ? ? ? ? ? ?補貨申請記錄 ? ? ? ? ? ? ? ? ? ?
css部分
.partner-content-container{ ? ? width: 100%; ? ? background: #fff; } .partner-list-header{ ? ? display: flex; ? ? justify-content: space-around;? ? height: 80rpx; ? ? line-height: 80rpx; ? ? border-bottom: 3rpx dashed #b2b3b2; ? ? margin: 0 20rpx; ? ? font-weight:bold; ? ? background: #fff; ? ? width: 100%; } .tab-fixed{ ? ? position: fixed; ? ? top: 0; ? ? left: 0; ? ? z-index: 1; } .partner-list-title{ ? ? width: 40%; ? ? text-align: center; } .icon-container{ ? ? display: flex; ? ? justify-content:center; ? ? align-items: center;
} .right-arrow{ ? ? width: 50rpx; ? ? margin-right: 20rpx; } .partner-list-content{ ? ? display: flex; ? ? justify-content: space-around; ? ? align-items: center; ? ? background: #fff; ? ? line-height: 100rpx; ? ? margin: 0 20rpx; } .co-wrapper{ ? ? width: 55%; ? ? box-sizing: border-box; } .item-desc{ ? ? width:45%; ? ? overflow: hidden; ? ? white-space: nowrap; ? ? text-overflow: ellipsis;
? ? text-align: center; } .co-btn{ ? ? background: rgb(14 37 199); ? ? font-size: 24rpx; ? ? margin-top: 10rpx; ? ? ? border-radius: 10rpx; ? ? color: #fff; ? ? padding: 18rpx 22rpx; ? ? margin:0 10rpx 0 0; }
js部分
data:{ ? ?navbarInitTop: 0, //導航欄初始化距頂部的距離 ?isFixedTop: false, //是否固定頂部 } /*監聽頁面滑動事件*/ ? ? onPageScroll: function(e) { ? ? ? ?let that = this; ? ? ? ?let scrollTop = parseInt(e.scrollTop); //滾動條距離頂部高度 ? ? ? ?let isSatisfy = scrollTop >= that.data.navbarInitTop ? true : false; ? ? ? ?//為了防止不停的setData, 這兒做了一個等式判斷。 只有處于吸頂的臨界值才會不相等? ? ?if (that.data.isFixedTop === isSatisfy) { ? ? ? return false; ? ? ?} ? ? ? ?that.setData({ ? ? ? ? ? ?isFixedTop:isSatisfy ? ? ? ?}) ? ? }, ? ? onShow: function () { ? ? ? ? let that = this; ? ? ? ? wx.createSelectorQuery().select('#operation-bar').boundingClientRect(function(rect) { ? ? ? ? ? ? if (rect && rect.top > 0) { ? ? ? ? ? ? ? ? var navbarInitTop = parseInt(rect.top); ? ? ? ? ? ? ? ? that.setData({ ? ? ? ? ? ? ? ? ? ? navbarInitTop: navbarInitTop ? ? ? ? ? ? ? ? }); ? ? ? ? ? ? ? ? ?console.log(that.data.navbarInitTop) ? ? ? ? ? ? } ? ? ? ? }).exec(); ? ? },
wx.().('#-bar').((rect)}rect值可能為null
有查詢節點需求可以用延時方法或者操作事件來獲取。
以上就是本文的全部內容微信小程序設置滾動條,希望對大家的學習有所幫助,也希望大家多多支持我們。