小程序在PC端打开时如何适配PC的宽度和高度?

发布于 7 年前作者 yongyan9297 次浏览最后编辑 7 年前来自 issues

大家好,我在小程序上适配PC的宽度和高度时在app.js中使用如下语句,却提示windowWidth和windowHeigth没有定义,麻烦问下我该如何设置呢?谢谢

wx.getSystemInfo({

success: function (res) {

windowWidth = res.windowWidth;

windowHeigth = res.windowHeight;

}

})

2 回复
dxiong
dxiong1 楼6 年前

这个好像是JS的基础问题吧~你定义了那2个变量了吗?

min01
min012 楼5 年前

let windowWidth = res.windowWidth;