zoukankan      html  css  js  c++  java
  • 微信小程序开发(六)获取手机信息

    // succ.js
    var app = getApp()
    Page({
      data: {
        mobileModel: '',  // 手机型号
        mobileePixelRatio: '',  // 手机像素比
        windowWidth: '',  // 窗口宽度
        windowHeight: '',  // 窗口高度
        language: '',  // 微信设置的语言
        version: '',  // 微信版本号
      },
      onLoad: function (e) {  // 获取参数
        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
            })
          }
        })
      }
    })
    
    // succ.wxml
    <view>手机型号:{{mobileModel}}</view>
    <view>手机像素比:{{mobileePixelRatio}}</view>
    <view>窗口宽度:{{windowWidth}}</view>
    <view>窗口高度:{{windowHeight}}</view>
    <view>微信设置的语言:{{language}}</view>
    <view>微信版本号:{{version}}</view>

    // succ.jsvar app = getApp()Page({  data: {    mobileModel: '',  // 手机型号    mobileePixelRatio: '',  // 手机像素比    windowWidth: '',  // 窗口宽度    windowHeight: '',  // 窗口高度    language: '',  // 微信设置的语言    version: '',  // 微信版本号  },  onLoad: function (e) {  // 获取参数    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        })      }    })  }})
    // succ.wxml<view>手机型号:{{mobileModel}}</view><view>手机像素比:{{mobileePixelRatio}}</view><view>窗口宽度:{{windowWidth}}</view><view>窗口高度:{{windowHeight}}</view><view>微信设置的语言:{{language}}</view><view>微信版本号:{{version}}</view>

  • 相关阅读:
    人物-IT-张志东:张志东
    人物-IT-任正非:任正非
    人物-IT-张朝阳:张朝阳
    院校-清华大学:清华大学
    人物-丁磊:丁磊
    人物-李彦宏:李彦宏
    人物-IT-马云:马云
    inittab
    initlocation
    initdb
  • 原文地址:https://www.cnblogs.com/hudaxian/p/14814204.html
Copyright © 2011-2022 走看看