欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序 獲取設(shè)備信息 API實(shí)例詳解

 更新時間:2016年10月02日 10:00:40   作者:順子_RTFSC  
這篇文章主要介紹了微信小程序 獲取設(shè)備信息 API實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下

獲取設(shè)備信息這里分為四種,

主要屬性:

網(wǎng)絡(luò)信息wx.getNetWorkType,

系統(tǒng)信息wx.getSystemInfo,

重力感應(yīng)數(shù)據(jù)wx.onAccelerometerChange,

羅盤數(shù)據(jù)wx.onCompassChange

wxml

<button type="primary" bindtap="getNetWorkType">獲取網(wǎng)絡(luò)類型</button>
<button type="primary" bindtap="getSystemInfo">獲取設(shè)備信息</button>
<button type="primary" bindtap="onAccelerometerChange">監(jiān)聽重力感應(yīng)數(shù)據(jù)</button>
<button type="primary" bindtap="onCompassChange">監(jiān)聽羅盤數(shù)據(jù)</button>

js

Page({
 data:{
  text:"Page system"
 },
 onLoad:function(options){
  // 頁面初始化 options為頁面跳轉(zhuǎn)所帶來的參數(shù)
 },
 /**
  * 獲取當(dāng)前網(wǎng)絡(luò)狀態(tài)
  */
 getNetWorkType: function() {
  wx.getNetworkType({
   success: function(res) {
    console.log(res)
   }
  })
 },

 /**
  * 獲取系統(tǒng)信息
  */
 getSystemInfo: function() {
  wx.getSystemInfo({
   success: function(res) {
    console.log(res)
   }
  })
 },
 /**
  * 監(jiān)聽重力感應(yīng)數(shù)據(jù)   
  *   - 帶on開頭的都是監(jiān)聽接收一個callback
  */
 onAccelerometerChange: function() {
  wx.onAccelerometerChange(function(res) {
   console.log(res)
  })
 },
  /**
  * 監(jiān)聽羅盤數(shù)據(jù)
  */
 onCompassChange: function() {
  wx.onCompassChange(function(res) {
   console.log(res)
  })
 },
 onReady:function(){
  // 頁面渲染完成
 },
 onShow:function(){
  // 頁面顯示
 },
 onHide:function(){
  // 頁面隱藏
 },
 onUnload:function(){
  // 頁面關(guān)閉
 }
})



感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論