ionic 使用 iframe 标签封装 Web App 时的一些技巧

使用 ionic 的 iframe 封装 web App 时可能会遇到没法全屏,页面连接没法点击等问题,这里展现下如何解决此问题javascript

一、使用 ion-content 标签封装 iframe 标签

<ion-content scroll="true" overflow-scroll="true">
  <iframe
    ng-src='{{myUrl}}'
    class="width-100 height-100"
    style="min-width: 100%;min-height: 100%;">
  </iframe>
</ion-content>

  ion-content 要设为 scroll="true" overflow-scroll="true"html

  iframe 要设为 class="width-100 height-100" 同时还要设置 min-width 和 min-height 为 100%,这样才能够全屏java

二、在页面对应的控制器中设定信任的安全链接

angular.module("start.controllers", [])
.controller('IndexCtrl', function($scope, $http, $sce) {
    var url = "http://m.yoururl.com";
    $scope.myURL = $sce.trustAsResourceUrl(url);
});

在 ionic 的 controllers 模块中找到对应的页面控制器,这里我是用的是 IndexCtrl,引入 $sce,而后设置信任的网址便可。web

三、其实还能够使用 cordova-plugin-whitelist 进行设置

在项目根目录下的config.xml中添加 access 控制apache

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/安全

<!-- Don't block any requests -->
<access origin="*" />
相关文章
相关标签/搜索