我收到以下错误消息
[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';
请帮忙!
答案 0 :(得分:5)
您的活动实际上是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
}