这个问题的解决方法有两种: 1:如果必须在onLoad的时候调用,那么在后面做一个异常检测, 如果screenWidth为0时候,赋一个默认值. 2:改在onReady的时候调用
提一个bug,关于安卓手机调用wx.getSystemInfo的问题首先这是一个随机bug,我们在华为荣耀9和金立上重现过. 在OnLoad的时候调用wx.getSystemInfo接口,代码如下: wx.getSystemInfo({ success: function(res) { self.data.screenWidth = res.windowWidth; self.data.screenHeight = res.windowHeight; console.log("onLoad getSystemInfo success!"); console.log("res.windowWidth:" + res.windowWidth); console.log("res.windowHeight:" + res.windowHeight); }, fail: function (res){ console.log("getSystemInfo fail!"); } }) 系统打印结果是 onLoad getSystemInfo success! res.windowWidth:0 res.windowHeight:0 换句话说就是:获取窗口的宽高失败了,但是却走了success回调.
2018-05-25