WeChat applet adapts to iphonex

 
// Determine whether it is what kind of device 
globalData is in app.js: {  
  isIphoneX: false ,  
  userInfo: null  
},  
onShow:function(){  
  let  that = this;  
  wx.getSystemInfo({  
    success:  res=>{  
      // console.log('手机信息res'+res.model)  
      let modelmes = res.model;  
      if (modelmes.search('iPhone X') != -1) {  
        that.globalData.isIphoneX = true  
      }  
  
    }  
  })  
},  

 

Get global variables in the onload method of the page js file that needs to be referenced

let isIphoneX = app.globalData.isIphoneX;
this .setData ({
isIphoneX: isIphoneX
})

Logic judgment of css in wxml file

<view class="{{isIphoneX?'linkCon':''}} flex "> </wiew>

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324841649&siteId=291194637