小程序增強 ScrollView 實例ScrollViewContext
ScrollViewContext
增強 ScrollView 實例,可通過 wx.createSelectorQuery 的 NodesRef.node 方法獲取。 僅在 scroll-view 組件開啟 enhanced 屬性后生效。
屬性
boolean scrollEnabled
滾動開關(guān)
boolean bounces
設(shè)置滾動邊界彈性 (僅在 iOS 下生效)
boolean showScrollbar
設(shè)置是否顯示滾動條
boolean pagingEnabled
分頁滑動開關(guān)
boolean fastDeceleration
設(shè)置滾動減速速率
boolean decelerationDisabled
取消滾動慣性 (僅在 iOS 下生效)
方法
ScrollViewContext.scrollIntoView(string selector)
滾動至指定位置
參數(shù)
string selector
元素選擇器
滾動至指定位置
ScrollViewContext.scrollTo(Object object)
滾動至指定位置
參數(shù)
Object object
屬性 類型 默認值 必填 說明
top number 否 頂部距離
left number 否 左邊界距離
velocity number 否 初始速度
duration number 否 滾動動畫時長
animated boolean 否 是否啟用滾動動畫
示例代碼
wx.createSelectorQuery()
.select('#scrollview')
.node()
.exec((res) => {
const scrollView = res[0].node;
scrollView.scrollEnabled = false;
})
作者:大學(xué)生新聞網(wǎng) 來源:大學(xué)生新聞網(wǎng)
- 小程序開始下拉刷新
- 開始下拉刷新。調(diào)用后觸發(fā)下拉刷新動畫,效果與用戶手動下拉刷新一致。
- 04-06 關(guān)注:0