本文实例讲述了微信小程序获取手机系统信息的方法。分享给大家供大家参考,具体如下:
1、效果展示
2、关键代码
rush:xml;">
手机型号:{{mobileModel}}
手机像素比:{{mobileePixelRatio}}
窗口宽度:{{windowWidth}}
窗口高度:{{windowHeight}}
微信设置的语言:{{language}}
微信版本号:{{version}}
rush:js;">
var app = getApp()
Page({
data: {
mobileModel:'',mobileePixelRatio:'',windowWidth:'',windowHeight:'',language:'',version:''
},onLoad: function () {
var that=this;
wx.getSystemInfo({
success: function(res) {
that.setData({
mobileModel:res.model,mobileePixelRatio:res.pixelRatio,windowWidth:res.windowWidth,windowHeight:res.windowHeight,language:res.language,version:res.version
})
}
})
}
})
这里通过wx.getSystemInfo函数来获取手机系统信息。具体参数说明与用法还可参考官网:https://mp.weixin.qq.com/debug/wxadoc/dev/api/systeminfo.html#wxgetsysteminfoobject
希望本文所述对大家微信小程序开发有所帮助。
原文地址:https://www.jb51.cc/weapp/34821.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。