小程序填坑
2018-12-06 本文已影响0人
visitor009
- 在后台配置的请求域名https://easy-mock.com/,在实际中不能包含www,如https://www.easy-mock.com/
2.swiper组件固定高度不能自适应,解决方案
// 1. 算了图片的宽高比,假设图片实际 w:900 h:300, 则 3:1
// 2. 图片宽度 / 3 = 高度 如 900 / 300 = 300 、600 / 300 = 200,默认图片宽度等于设备宽
// 3. 计算后赋值给swiper
// wxml
<swipe style="height:{{bannerHeight}}px">
<swiper-item><image src="" mode="widthFix"></image></swiper-item>
</swiper>
// js
let bannerHeight = 150;
wx.getSystemInfo({
success(res) {
winWidth = res.windowWidth;
}
})
Page({
bannerHeight: winWidth / 3
})