离子2 - inappbrowser“browser.on(...)。subscribe不是一个函数”错误 [英] ionic 2 - inappbrowser "browser.on(...).subscribe is not a function" error

查看:541
本文介绍了离子2 - inappbrowser“browser.on(...)。subscribe不是一个函数”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照 http://ionicframework.com/docs/native/in- app-browser / 文档,可在以下步骤中使用:

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不是一个函数”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆