微信小程序获取手机系统信息的方法【附源码下载】

本文实例讲述了微信小程序获取手机系统信息的方法。分享给大家供大家参考,具体如下:

发展壮大离不开广大客户长期以来的信赖与支持,我们将始终秉承“诚信为本、服务至上”的服务理念,坚持“二合一”的优良服务模式,真诚服务每家企业,认真做好每个细节,不断完善自我,成就企业,实现共赢。行业涉及混凝土搅拌罐等,在成都网站建设全网整合营销推广、WAP手机网站、VI设计、软件开发等项目上具有丰富的设计经验。

1、效果展示

微信小程序获取手机系统信息的方法【附源码下载】

2、关键代码

index.wxml布局文件代码

手机型号:{{mobileModel}}
手机像素比:{{mobileePixelRatio}}
窗口宽度:{{windowWidth}}
窗口高度:{{windowHeight}}
微信设置的语言:{{language}}
微信版本号:{{version}}

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函数来获取手机系统信息。具体参数说明与用法还可参考官网:https://mp.weixin.qq.com/debug/wxadoc/dev/api/systeminfo.html#wxgetsysteminfoobject

3、源代码点击此处本站下载

希望本文所述对大家微信小程序开发有所帮助。


网页名称:微信小程序获取手机系统信息的方法【附源码下载】
新闻来源:http://scyanting.com/article/jghjep.html