这几天做小程序,有些页面都是全屏的背景,在安卓上背景是固定的,而在ios上上拉下拉出现白色,测试说体验不太好,一开始我以为是下拉上拉刷新造成的,关闭了依然是这样。为了体验好点,可以按一下解决:

方式一:

  可以在page.json文件内配置 :"backgroundColor": "#ccc" 属性,这个方法比较便捷。但是对于一些全屏背景的页面体验还不是很好

方式二:

  对于一些全屏背景页面,我们可以让背景固定这样体验会好点,可以按以下进行操作:

  1》page.json设置 "disableScroll":true ; 表示:设置为 true 则页面整体不能上下滚动;只在 page.json 中有效,无法在 app.json 中设置该项

  2》对于一些页面内容太多,需要页面需要上下滑动的可以在page.wxml页面这么处理

<scroll-view scroll-y style="height:{{wh}}px;" bindscrolltolower="onBottom">

</scroll-view>

  3》page.js

wx.getSystemInfo({
    success: function (res) {
    that.setData({
        "wh": res.windowHeight
    })
    }
})

  4》全屏背景样式

  page{background: url(xxx.png) no-repeat center center fixed;background-size: cover; } 

 

相关文章:

  • 2022-02-20
  • 2021-09-28
  • 2022-12-23
  • 2022-01-05
  • 2022-01-24
  • 2022-01-07
  • 2021-07-21
猜你喜欢
  • 2022-12-23
  • 2022-01-07
  • 2021-09-13
  • 2022-12-23
  • 2021-09-03
  • 2021-12-11
  • 2022-01-20
相关资源
相似解决方案