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

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

1、使用 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"

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

2、在页面对应的控制器中设定信任的安全连接
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,然后设置信任的网址即可。

3、其实还可以使用 cordova-plugin-whitelist 进行设置

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

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

<!-- Don't block any requests -->
<access origin="*" />

转载于:https://my.oschina.net/sallency/blog/747152

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值