微信小程序scroll-view,
縱向滑動注意點
必須設置高度,除了全屏幕的scrollview,其他的高度不應該寫死,應該動態計算,
let windowHeight = wx.getSystemInfoSync().windowHeight // 屏幕的高度
let windowWidth = wx.getSystemInfoSync().windowWidth // 屏幕的寬度
let ratio = 750 / windowWidth;
this.setData({
scroll_height: (windowHeight - 100) * ratio
})
橫向滑動注意點
1.scroll-view 中的需要滑動的元素不可以用 float 浮動;
2.scroll-view 中的包裹需要滑動的元素的大盒子用 display:flex; 是沒有作用的;
3.scroll-view 中的需要滑動的元素要用 dislay:inline-block; 進行元素的橫向編排;
4.包裹 scroll-view 的大盒子有明確的寬和加上樣式–> overflow:hidden;white-space:nowrap;