object参数说明:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| success | Function | 是 | 接口调用成功的回调 |
| fail | Function | 否 | 接口调用失败的回调函数 |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
success回调参数说明:
| 参数 | 说明 | 最低版本 |
|---|---|---|
| model | 手机型号 | |
| pixelRatio | 设备像素比 | |
| screenWidth | 屏幕宽度 | 1.1.0 |
| screenHeight | 屏幕高度 | 1.1.0 |
| windowWidth | 可使用窗口宽度 | |
| windowHeight | 可使用窗口高度 | |
| language | 微信设置的语言 | |
| version | 微信版本号 | |
| system | 操作系统版本 | |
| platform | 客户端平台 | |
| fontSizeSetting | 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px | 1.5.0 |
| SDKVersion | 客户端基础库版本 | 1.1.0 |
例子:
demo https://github.com/oopsguy/wechat-app-examples/tree/master/DouBanBookApp 中,
列表放在了<scroll-view></<scroll-view>里,
<scroll-view scroll-y="true" style="height:{{scrollHeight}}px"
bindscrolltolower="scrollLowerEvent">
...
</scroll-view>
获取系统数据,并设置style(scrollHeight已在data中初始化了):
wx.getSystemInfo({
success: (res) => {
this.setData({
scrollHeight: res.windowHeight - (100 * res.windowWidth / 750) //80为顶部搜索框区域高度 rpx转px 屏幕宽度/750
});
}
})
本文详细介绍了微信小程序中如何使用wx.getSystemInfo接口获取设备的系统信息,包括手机型号、屏幕尺寸、微信版本等关键参数,并展示了如何利用这些信息设置scroll-view组件的高度。
1688

被折叠的 条评论
为什么被折叠?



