源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2021-03-11 20:56 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:微信小程序获取手机系统信息的方法【附源码下载】
本文实例讲述了微信小程序获取手机系统信息的方法。分享给大家供大家参考,具体如下: [b]1、效果展示[/b] [img]http://files.jb51.net/file_images/article/201712/2017127153304067.gif?2017117153324[/img] [b]2、关键代码[/b] 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函数来获取手机系统信息。具体参数说明与用法还可参考官网:[url=https://mp.weixin.qq.com/debug/wxadoc/dev/api/systeminfo.html#wxgetsysteminfoobject]https://mp.weixin.qq.com/debug/wxadoc/dev/api/systeminfo.html#wxgetsysteminfoobject[/url] [b]3、源代码[/b]点击此处[url=http://xiazai.jb51.net/201712/yuanma/wxapp_api_getSystemInfo(jb51.net).rar][b]本站下载[/b][/url]。 希望本文所述对大家微信小程序开发有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部