- 在imageLoad里面拿到图片宽度和高度,以及手机屏幕宽度,动态的给swiper高度,某些机型会出现图片一直闪一直闪 ,感觉一致在重新计算图片的宽度,之前一直没有出现过这个问题,IOS12.1.4没有出现,IOS12.4出现,然后某些安卓机型也会出现
- 不会一直闪,会直接加载出来
- imageLoad里面动态给swiper高度
- 提供一个最简复现 Demo
框架类型 | 问题类型 | API/组件名称 | 终端类型 | 微信版本 | 基础库版本 |
---|---|---|---|---|---|
小程序 | Bug | swiper | 客户端 | 7.0.4 | 2.7.1 |
- 在imageLoad里面拿到图片宽度和高度,以及手机屏幕宽度,动态的给swiper高度,某些机型会出现图片一直闪一直闪 ,感觉一致在重新计算图片的宽度,之前一直没有出现过这个问题,IOS12.1.4没有出现,IOS12.4出现,然后某些安卓机型也会出现
- 不会一直闪,会直接加载出来
- imageLoad里面动态给swiper高度
- 提供一个最简复现 Demo
2 个回答
建议在swiper外就将图片预加载且计算好长高
而且获取系统信息获取一次即可 不要放在imageloadL里
麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
imageLoad: function (e) {
var _this = this;
var imgWidth = (1-0.06)*wx.getSystemInfoSync().windowWidth;
var originWidth = e.detail.width;
var originHeight = e.detail.height;
var imgHeight = imgWidth * originHeight / originWidth;
_this.setData({
height: parseInt(imgHeight)
})
},
<swiper style="height: {{ height }}px;" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" circular="{{ circular }}" bindchange="swiperchange">
<block>
<block wx:for="{{ banner }}" wx:key="*this">
<swiper-item>
<view class="swiper-item">
<image bindload='imageLoad' src="{{ item.image }}" mode="widthFix" style="width: 100%;" ></image>
</view>
</swiper-item>
</block>
</block>
</swiper>
iphone xr 版本12.2
代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)提供下这个格式的
https://developers.weixin.qq.com/s/g53P5fm5739K
我还想再问一下那个,微信小程序能不能拿到当前运行的环境是开发还是体验还是线上呢