问题描述
我按照文档,可在以下步骤中使用:
I follow this http://ionicframework.com/docs/native/in-app-browser/ document for use inappbrowser and try with below steps :
1-安装
ionic cordova plugin add cordova-plugin-inappbrowser
npm install --save @ionic-native/in-app-browser
2 - 将此插件添加到app.module.ts提供商
2 - Add this plugin to app.module.ts provider
3 - 添加到构造函数:
3 - add to constructor :
constructor(private iab: InAppBrowser) { }
4-并在启动方法中使用它,如下所示:
4- and use it in launch method like this :
import { InAppBrowser,InAppBrowserEvent} from '@ionic-native/in-app-browser';
launch(urlc){
let url = 'https://example.com/';
let browser = this.iab.create(url, '_blank', 'location=yes');
browser.on('loadstart').subscribe((ev: InAppBrowserEvent) => {
this.close_status=true;
});
}
但是当服务和调用启动方法时,我看到了这个错误:
but when serve and call launch method I see this error :
Runtime Error
browser.on(...).subscribe is not a function
推荐答案
InAppBrowser
是一个cordova插件,因为当使用 ionic serve
在浏览器中运行应用程序时,它不可用。
InAppBrowser
is a cordova plugin, and because of that, it's not available when running the app in the browser with ionic serve
.
尝试在模拟器/真实设备上运行应用程序以使用该插件。
Try to run the app on a simulator / real device to use the plugin.
这篇关于离子2 - inappbrowser“browser.on(...)。subscribe不是一个函数”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!