1

我有一个博客,我想将其转换为离子应用程序。我使用InAppBrowser插件,但问题是当我按下后退按钮时,它会进入我的默认离子home页面。

我按照以下步骤操作:

ionic start myblog

ionic platform add android

ionic cordova plugin add cordova-plugin-inappbrowser

npm install --save @ionic-native/in-app-browser

然后添加provider并写入以下内容app.modulehome.ts

import { InAppBrowser } from '@ionic-native/in-app-browser';

constructor(private iab: InAppBrowser) { }


...


const browser = this.iab.create('https://ionicframework.com/','_self','location=no');
browser.show();

也不location=no工作。像android ionic 提供的webview?? 谁能帮我吗 ?任何帮助表示赞赏。:)

4

2 回答 2

5

来自我的 github 存储库的简单排序解决方案

home.html

<iframe  height="100%" width="100%" [src]="urlpaste()"></iframe>

并且在home.ts

import { Component } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  url: any;
  constructor(private sanitize: DomSanitizer) {}
  urlpaste(){
    this.url = "https://hackerrankgeek.wordpress.com/";
    return this.sanitize.bypassSecurityTrustResourceUrl(this.url);
  }
}
于 2017-11-16T09:25:25.657 回答
3

在不安装任何插件的简单方法中,您可以使用标签来定义您博客的网址。例如在 home.ts 中:

    import { DomSanitizer } from '@angular/platform-browser';
    url: any;
    constructor(private sanitize: DomSanitizer){
    this.url = sanitize.bypassSecurityTrustResourceUrl("YOUR_URL");
    }

并在home.html

<iframe  height="100%" width="100%" [src]="url" name="iframe_a"></iframe>

尝试这个。

于 2017-11-15T05:26:15.587 回答