• 二、ionic如何使用外链


    1、ionic如何使用外链并返回原有页面?
    html如下:

    对应的controller如下:

    (function() {
        angular.module('app').controller('extraLinkCtrl', extraLinkCtrl);
        extraLinkCtrl.$inject = ['$scope','$stateParams','$state'];
    
        function extraLinkCtrl($scope, $stateParams,$state) {
                var vm = this;
    
                document.getElementsByName('extraLink')[0].src = 'https://' + $stateParams.link;//外链的链接地址
                document.getElementsByName('extraLink')[0].height = window.screen.height;//高度自适应
                vm.goHomePage = goHomePage;
                function goHomePage () {
                  $state.go('homePage');
                }
            }
        })();

    2、使用过程中出现的问题

    • 无法访问外部url的问题--两个步骤解决:
    1. iframe的src属性用ng-src属性替代,并指明绑定对象: ng-src="{{targetUrl}}"
    2. 在controller里,调用$sce: $scope.targetUrl = $sce.trustAsResourceUrl(url)
    • 高度无法最大化的问题--两个步骤解决:
    1. ion-content 属性里添加  scroll="true" overflow-scroll="true"
    2. iframe的style里添加 min-height: 100%
  • 相关阅读:
    cf B. Vasily the Bear and Fly
    hdu 3339 In Action
    hdu 六度分离
    cf A. Vasily the Bear and Triangle
    cf C. Secrets
    2.19学习笔记|2.20学习笔记
    VAE代码学习
    2.9日学习记录
    deconvolution反卷积(待学习)
    gamma分布学习
  • 原文地址:https://www.cnblogs.com/gunelark/p/7290700.html
Copyright © 2020-2023  润新知