微信H5一屏幕適配(iPhone機型)

一、iPhone尺寸圖
iPhone尺寸.png

微信H5.jpg
二、代碼
<script>
export default {
    data(){
        return{
            clientHeight:'',
            isIphone5:true,
            isIphone6:false,
            isIphone7Plus:false,
            isIphoneX:false,
            isIphoneXsMax:false
        }
    },
    created(){
      // 獲取瀏覽器可視區(qū)域高度
      this.clientHeight =   `${document.documentElement.clientHeight}`      
      window.onresize = function temp() {
        this.clientHeight = `${document.documentElement.clientHeight}`;
      };
      if(this.clientHeight<554){
        this.isIphone5=true;
        this.isIphone6=false;
        this.isIphone7Plus=false;
        this.isIphoneX=false;
        this.isMate20Pro=false;
        this.isIphoneXsMax=false;
      }else if(this.clientHeight <623){
        this.isIphone5=false;
        this.isIphone6=true;
        this.isIphone7Plus=false;
        this.isIphoneX=false;
        this.isMate20Pro=false;
        this.isIphoneXsMax=false;
      }else if(this.clientHeight <641){
        this.isIphone5=false;
        this.isIphone6=false;
        this.isIphone7Plus=true;
        this.isIphoneX=false;
        this.isMate20Pro=false;
        this.isIphoneXsMax=false;
      }else if(this.clientHeight <672){
        this.isIphone5=false;
        this.isIphone6=false;
        this.isIphone7Plus=false;
        this.isIphoneX=true;
        this.isMate20Pro=false;
        this.isIphoneXsMax=false;  
      }else if(this.clientHeight <725){
        this.isIphone5=false;
        this.isIphone6=false;
        this.isIphone7Plus=false;
        this.isIphoneX=false;
        this.isMate20Pro=true;
        this.isIphoneXsMax=false;  
      }else{
        this.isIphone5=false;
        this.isIphone6=false;
        this.isIphone7Plus=false;
        this.isIphoneX=false;
        this.isMate20Pro=false;
        this.isIphoneXsMax=true;   
      }
    }
}
</script>
<style>
body,html{background-color: #3dc1b2;height: 100%;width: 100%;}
#app{height: 100%;}
.mint-toast-text{color: #fff;}
</style>

<style scoped>
.childIphone5{bottom: 2rem;}
.adultIphone5{bottom: .6rem;}
.childIphone6{bottom: 2.37rem;}
.adultIphone6{bottom: .86rem;}
.childIphone7Plus{bottom: 2.37rem;}
.adultIphone7Plus{bottom: .86rem;}
.childIphoneX{bottom: 3.4rem;}
.adultIphoneX{bottom: 1.68rem;}
.childMate20Pro{bottom: 3.88rem;}
.adultMate20Pro{bottom: 2.08rem;}
.childIphoneXsMax{bottom: 3.3rem;}
.adultIphoneXsMax{bottom: 1.5rem;}
</style>


最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容