wx.getSystemInfo windowWidth为0
发布于 6 年前 作者 jiejin 5962 次浏览 来自 问答

navigateto之后进去页面,不管从onload  onready 还是onshow都有概率出现取不到长宽的问题,手机是小米5s

3 回复

小程序首页

/**

  * 生命周期函数–监听页面加载

  */

onLoad: function (options) {

var app = getApp();

var that = this;

//读取屏幕尺寸

var sysInfo = wx.getSystemInfo({

success: function (res) {

var windowWidth = res.windowWidth;

that.setData({ windowWidth });

},

});

wx.navigateTo({

url: ‘/pages/guide-page/guide-page’,

});

},

跳转后的页面

<!–pages/guide-page/guide-page.wxml–>

<view class=“root”>

<swiper class=“swiper” style=‘width:100%;height:{{systemInfo.windowHeight}}px’>

<swiper-item class=“swiper-item” style=“width:100%;height:100%”>

<image src=http://picture.fiteam.mejimeji.net/guide-page/1.png style=“width:100%;height:100%” class=“slide-image” mode=“aspectFit” />

</swiper-item>

<swiper-item class=“swiper-item” style=“width:100%;height:100%”>

<image src=http://picture.fiteam.mejimeji.net/guide-page/2.png style=“width:100%;height:100%” class=“slide-image” mode=“aspectFit” />

</swiper-item>

<swiper-item class=“swiper-item” style=“width:100%;height:100%”>

<image src=http://picture.fiteam.mejimeji.net/guide-page/3.png style=“width:100%;height:100%” class=“slide-image” mode=“aspectFit” />

</swiper-item>

<swiper-item class=“swiper-item” style=“width:100%;height:100%”>

<image src=http://picture.fiteam.mejimeji.net/guide-page/4.png style=“width:100%;height:100%” class=“slide-image” mode=“aspectFit” />

</swiper-item>

</swiper>

<!-- <image src="/images/icons/enter_fiteam.png" class=‘enter’ mode=“aspectFit”></image> -->

</view>

你好,请提供一下出现问题的机型和微信版本,以及能复现问题的简单代码示例和出现问题的截图。

回到顶部