vue iframe嵌套頁面高度自適應 (ios 寬度擴大的bug , ios展示比例問題)


<template>
  <div class="card-index pt-relative">
    <div id="wrapper" :style="'height:'+Height+'px;'">
      <iframe
        v-if="iframeType"
        :src="srcUrl"
        sandbox="allow-forms allow-same-origin allow-scripts allow-top-navigation allow-modals"
        id="iframe"
        marginwidth="0"
        marginheight="0"
        align="center"
      ></iframe>

 

      <iframe
        v-else
        :src="srcUrl"
        sandbox="allow-forms allow-same-origin allow-scripts allow-top-navigation allow-modals"
        id="iframe"
        scrolling="no"
        marginwidth="0"
        marginheight="0"
        align="center"
      ></iframe>

 

   
    </div>
  </div>
</template>
 
 
 data() {
    return {
      srcUrl: "",
      iframeType: false
    };
  },
 created() {
 var u = navigator.userAgent;
    var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android終端
    // var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios終端
    // console.log('是否是Android:'+isAndroid);
    // console.log('是否是iOS:'+isiOS);
    if (isAndroid) {
      this.iframeType = true;
    } else {
      this.iframeType = false;
    }
}

<style lang='scss' scoped>
.card-index /deep/ {
  width: 100%;
  position: relative;
  #iframe {
    width: 100%;
    height: 100%;
    overflow: scroll;
    -webkit-overflow-scrolling: touch;
    min-width: 100%;
    *width: 100%;
    width: 1px;
  }

  #wrapper {
    -webkit-overflow-scrolling: touch;
    overflow: auto;
    position: fixed;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
  }
 
</style>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 頁面嵌套iframe時,怎樣讓iframe高度根據自身內容高度自適應 iframe 高度寬度自適應 關於iframe頁面高度自適應的問題 iframe嵌套跨域子頁面變化高度自適應 iOS 字符串的寬度和高度自適應