我看过其他类似的问题,但仍然感到困惑。当我使用ionic serve
运行我的应用时,我的控制台告诉我:
ionic-pro.min.js:1 the cordova-plugin-ionic plugin is not installed. Install it for better device information for runtime errors.
但是当我跑步时:
cordova plugin add cordova-plugin-ionic --variable APP_ID=app_id --variable CHANNEL_NAME=Production
它说:
Plugin "cordova-plugin-ionic" already installed on android.
Plugin "cordova-plugin-ionic" already installed on browser.
Plugin "cordova-plugin-ionic" already installed on ios.
我觉得这与我的其他一个问题有关,即Ionic Pro的部署服务没有按预期工作。
这是我的环境:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.14.0
ionic (Ionic CLI) : 3.14.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 2.1.4
Cordova Platforms : android 6.1.2 browser 4.1.0 ios 4.1.1
Ionic Framework : ionic-angular 3.0.1
System:
ios-deploy : 1.9.1
ios-sim : 5.0.13
Node : v6.11.0
npm : 2.15.12
OS : macOS Sierra
Xcode : Xcode 9.0.1 Build version 9A1004
Misc:
backend : pro
答案 0 :(得分:4)
在app.component.ts文件中:
在平台就绪之后声明rootpage值,如下所示。
var list = [{id:3, value:"value1"}, {id:4, value:"value2"}];
var result = {};
for (var i = 0; i < list.length; i++){
result[list[i].id] = list[i].value;
}
console.log(result);
答案 1 :(得分:0)
我通过检查cordova
handleError(err: any): void {
if (this.platform.is('cordova')) {
// This will only print when on iOS
console.log('I am an iOS device!');
Pro.monitoring.handleNewError(err);
// Remove this if you want to disable Ionic's auto exception handling
// in development mode.
this.ionicErrorHandler && this.ionicErrorHandler.handleError(err);
} }
并添加到平台就绪:
this.platform.ready().then(() => {
/** Pro handlings */
Pro.init('7dafc58e', {
appVersion: '0.0.1'
})
try {
this.ionicErrorHandler = injector.get(IonicErrorHandler);
} catch (e) {
// Unable to get the IonicErrorHandler provider, ensure
// IonicErrorHandler has been added to the providers list below
}
this.AppCenterCrashes.setEnabled(true).then(() => {
this.AppCenterCrashes.lastSessionCrashReport().then(report => {
Pro.monitoring.log(JSON.stringify({ report: report }), { level: 'error' })
});
});
});
我认为更好的选择是检查平台是否为cordova
,然后将其添加到函数中。