本文实例讲述了微信小程序获取手机系统信息的方法。分享给大家供大家参考,具体如下:
1、效果展示
2、关键代码
index.wxml布局文件代码
<view>手机型号:{{mobilemodel}}</view> <view>手机像素比:{{mobileepixelratio}}</view> <view>窗口宽度:{{windowwidth}}</view> <view>窗口高度:{{windowheight}}</view> <view>微信设置的语言:{{language}}</view> <view>微信版本号:{{version}}</view>
index.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函数来获取手机系统信息。具体参数说明与用法还可参考官网:
3、源代码点击此处。
希望本文所述对大家微信小程序开发有所帮助。
如对本文有疑问, 点击进行留言回复!!
150Vue-Router路由概述+基本使用router-view占位符+重定向redirect
网友评论