我创建了一个全新的空白 ionic 3 应用程序并运行命令“npm i airwatch-sdk-plugin”,然后运行“ionic cordova platform add android”。
在 app.components 我有这个代码......
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
window.plugins.airwatch.setSDKEventListener( function( event, error ) {
if( event === "initSuccess" ) {
alert( 'airwatch initialised' );
}
},
(error) => {
alert( 'airwatch error: ' + JSON.stringify( error ) );
});
});
}
}
Windows 10 上的编辑器 Visual Studio Code 报告插件在类型窗口中不存在。我可以将此行更改为...
(<any>window).plugins
删除编辑器错误,但是当我使用“ionic serve”运行项目时,浏览器会报告此错误...
TypeError:无法读取未定义的属性“airwatch”
我究竟做错了什么?