miniprogram-demo/packageAPI/pages/get-system-info/get-system-info.js

56 lines
1.1 KiB
JavaScript
Raw Normal View History

// pages/API/get-system-info/get-system-info.js
Page({
data: {
systemInfo: {}
},
getSystemInfo() {
const that = this
wx.getSystemInfo({
success(res) {
that.setData({
systemInfo: res
})
}
})
2020-12-08 10:38:16 +08:00
},
getSystemInfoSync() {
const that = this;
try {
const res = wx.getSystemInfoSync()
2021-08-10 15:29:31 +08:00
console.log(res)
2020-12-08 10:38:16 +08:00
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
that.setData({
systemInfo: res
});
} catch (e) {
// Do something when catch error
}
},
2021-12-30 10:55:50 +08:00
getSystemInfoAsync () {
const that = this;
console.log('getSystemInfoAsync start')
wx.getSystemInfoAsync({
success(res) {
that.setData({
systemInfo: res
})
},
complete (res) {
console.log('getSystemInfoAsync complete: ', res)
}
})
console.log('getSystemInfoAsync end')
},
2020-12-08 10:38:16 +08:00
clearInfo() {
this.setData({
systemInfo: {}
})
},
})