简体   繁体   English

无法侦听Ionic InAppBrowser返回的事件

[英]Unable to listen for events returned from Ionic InAppBrowser

  let browser = new InAppBrowser(uri, '_system', 'location=no,clearsessioncache=yes,clearcache=yes');
  function obTest(event:string) {
    console.log('firing obTest');
    browser.on(event).subscribe(value => {
      console.log(value);
    }, err => {
      console.log(err);
    }, () => {
      console.log('object');
      debugger;
    });
  }
  obTest("loadstart");
  obTest("loadstop");
  obTest("loaderror");
  obTest("exit");

browser.on(event) is returning an observable that I'm trying to listen for, none of the console.logs are firing. browser.on(event)返回一个我正在尝试监听的观察值,没有console.logs触发。 I must be consuming the observable incorrectly. 我必须不正确地食用可观察物。 In the ios emulator the uri i specified is opening so the events should be called. 在ios仿真器中,指定的uri正在打开,因此应调用事件。 console.log calls outside of the observable are working as well. 可观察对象之外的console.log调用也可以正常工作。

the ionic command needs to have the -c flag in order to print console logs to the terminal, I needed to use the command ionic emulate -ios -l -c . ionic命令需要具有-c标志才能将控制台日志打印到终端,我需要使用命令ionic emulate -ios -l -c。 The syntax for listening for event is correct. 侦听事件的语法是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM