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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

FutrueJet   2020-05-16 我要评论

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

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

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

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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们