属性类型 'url' 在类型 'Event' 上不存在



我收到以下错误消息

[ts] Property type 'url' does not exist on type 'Event'.
any

这是我使用的 TypeScript (JavaScript(

document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
      var ref = window.open(url, '_blank', 'location=yes');
      ref.addEventListener('loadstart', function(event) { });
      ref.addEventListener('loadstop', function(event) { });
      ref.addEventListener('loaderror', function(event) { alert( event.url ) });//Property type 'url' does not exist on type 'Event'.
    }

这是我的进口

import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { Event } from '@angular/router';

请帮忙!

您的事件实际上是 InAppBrowserEvent 类型,因此请导入它并用它注释参数:

import { InAppBrowser, InAppBrowserEvent } from '@ionic-native/in-app-browser';
...
...
function onDeviceReady() {
  var ref = window.open(url, '_blank', 'location=yes');
  ref.addEventListener('loadstart', function(event) { });
  ref.addEventListener('loadstop', function(event) { });
  ref.addEventListener('loaderror', function(event: InAppBrowserEvent) { alert( event.url ) }); //InAppBrowserEvent has 'url' property
}

相关内容

  • 没有找到相关文章

最新更新