小程序获取屏幕宽度

https://developers.weixin.qq.com/miniprogram/dev/api/base/system/system-info/wx.getSystemInfo.html

写在app.js里了 随时可以调用

 onShow: function (options) {
    console.log("app-onShow");
    let that = this;
    //显示客服入口
// 获取系统参数
    wx.getSystemInfo({
      success: res => {
        console.log(res)
        that.globalData.screenWidth = res.screenWidth;
        that.globalData.screenHeight = res.screenHeight;
      }
    })
  }
  data: {
    screenWidth: app.globalData.screenWidth,
   
  },

  
    
      
    
  

 

你可能感兴趣的:(get,技能,小程序)