【发布时间】:2017-06-02 10:56:53
【问题描述】:
我在 ionic 2 应用程序中使用 inappbrowser 插件,如下所示:
import {InAppBrowser} from 'ionic-native';
并像这样使用它:
launch(url){
this.browser = new InAppBrowser( url, "_blank", "EnableViewPortScale=yes,closebuttoncaption=Done" );
this.browser.on("exit")
.subscribe(
() => {
this.close_event=true;
},
err => {
console.log("InAppBrowser Loadstop Event Error: " + err);
});
}
在 html 中:
<button ion-button icon-right color="danger" (click)="launch('https://www.example.com')">launch
<ion-icon name="refresh"></ion-icon>
当第一次点击launch button 并关闭浏览器后,exit event 不会触发,但是当第二次点击启动按钮并且关闭浏览器后exit event 会触发
【问题讨论】:
-
您使用的是 old 版本的 Ionic Native,对吧?因为在上一个版本中,可用的方法发生了一些变化(docs)
-
我尝试使用新方法和旧方法,但 inappbrowser 事件在第二次调用中触发
标签: ionic2 cordova-plugins inappbrowser