微信小程序任意图片铺满整个屏幕(且超过实现滑动)

大家好,我是假技术po主,欢迎大家关注我!!!接下来我将以一个QQ小程序开发实例给大家展示(其他小程序开发也同样适用),往下看:
例如在下面这个文件中实现:
在这里插入图片描述

starInfo.js:
Page({
  data: {
    sysheight:'',
    InfoImg:'../../images/guanzhu.png'
  },
  onLoad: function (options) {
    var that=this;
    qq.getSystemInfo({
      success: (res) => {
        that.setData({sysheight:res.windowHeight});//这很关键,可以获取屏幕高度,设置好scroll-view的高度。
      }
    });
   qq.showLoading({
      title: 'loading...'
    });
  },
  //监测所载(InfoImg:'../../images/guanzhu.png')图片是否加载成功
  successload:function(res){
    qq.hideLoading();
  }
})
starInfo.qml:
<scroll-view  scroll-y="{{true}}" style="width:100%;height:{{sysheight}}px;">
    <image src="{{InfoImg}}" mode="widthFix" class="infoImg" bindload="successload"/>
</scroll-view>
starInfo.qss:
page{
    width: 100%;
    height: 100%;
}
.infoImg{
    width: 100%;
    height: 100%;
}

OK了,功能实现了,不信,你可以去试试,后期更多假技术po主精彩技术文章,期待你的关注!!!

发布了67 篇原创文章 · 获赞 25 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_41104871/article/details/96478311