Ionic InAppBrowser.on('loadstart ').subscribe无法读取undefined的属性(阅读' subscribe ')

mpbci0fu  于 2023-04-03  发布在  Ionic
关注(0)|答案(1)|浏览(163)

在“browser.on”上抛出未定义的错误。

public openWithInAppBrowser(url: string) {
    let target = "_blank";
    var browser = this.theInAppBrowser.create(url, target, this.options);

    browser.on('loadstart').subscribe(event => {
      console.log(event.url);
    });  
}

构造函数代码包含:

constructor(public storage: Storage, private router: Router, private navCtrl: NavController, private theInAppBrowser: InAppBrowser,
          private toastCtrl: ToastController)
jdgnovmf

jdgnovmf1#

在我的情况下,订阅未定义的错误是由于缺少安装的npm install cordova-plugin-inappbrowser
检查https://ionicframework.com/docs/v5/native/in-app-browser也考虑这个答案https://stackoverflow.com/a/44328903/14655526

相关问题