wx.getSystemInfo is deprecated. wx.getSystemInfoSync is deprecated.
wx.getSystemInfo is deprecated. wx.getSystemInfoSync is deprecated.
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Windows | 10 | HBuilderX |
HBuilderX | 4.56 | |
第三方开发者工具 | 稳定版 Stable Build(1.06.2412050) | |
基础库 | 3.7.10 |
操作步骤:
export default {
onLaunch: function() {
uni.getSystemInfo({
success: function(e) {}
})
}
}
预期结果:
希望能编译成微信小程序最新的API
实际结果:
微信小程序开发者工具会警告:
wx.getSystemInfo is deprecated.Please use wx.getSystemSetting/wx.getAppAuthorizeSetting/wx.getDeviceInfo/wx.getWindowInfo/wx.getAppBaseInfo instead.
wx.getSystemInfoSync is deprecated.Please use wx.getSystemSetting/wx.getAppAuthorizeSetting/wx.getDeviceInfo/wx.getWindowInfo/wx.getAppBaseInfo instead.
3 回复
不都提示出来了嘛?停止维护了啊 不是uniapp的问题
请使用 wx.getSystemSetting、wx.getAppAuthorizeSetting、wx.getDeviceInfo、wx.getWindowInfo、wx.getAppBaseInfo 代替
参考文档:https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.getSystemInfoSync.html
uni 提供的方案uni.xxxx,不是可以 把底层使用的逻辑替换 或 提供新的API么,或者 直接 在官网上告知 让用户自行实现。
根据微信小程序官方文档,wx.getSystemInfo
和wx.getSystemInfoSync
确实已被标记为废弃,建议使用新的细分API替代。
在uni-app中,你可以这样修改代码:
export default {
onLaunch: function() {
// 替代方案1:使用uni.getSystemInfoAsync
uni.getSystemInfoAsync().then(res => {
console.log(res)
})
// 替代方案2:使用细分API
const deviceInfo = uni.getDeviceInfo()
const windowInfo = uni.getWindowInfo()
const appBaseInfo = uni.getAppBaseInfo()
// 其他需要的信息...
}
}