Cod*_*Spy 3 ionic-framework ionic-native ionic4
我使用下面的最新版本的Ionic CLI v4.9.0创建了新的Ionic 3应用程序
$ ionic start Ionic3Project blank --type ionic-angular
Run Code Online (Sandbox Code Playgroud)
默认情况下会创建V4 Ionic项目。
然后我在这里按照步骤进行本机应用程序版本插件
导入app.module.ts文件时遇到以下控制台错误
Uncaught Error: Invalid provider for the NgModule 'AppModule' - only instances of Provider and Type are allowed, got: [StatusBar, ?[object Object]?, ...]
at syntaxError (compiler.js:486)
at compiler.js:15784
at Array.forEach (<anonymous>)
at CompileMetadataResolver._getProvidersMetadata (compiler.js:15752)
at CompileMetadataResolver.getNgModuleMetadata (compiler.js:15320)
at JitCompiler._loadModules (compiler.js:34413)
at JitCompiler._compileModuleAndComponents (compiler.js:34374)
at JitCompiler.compileModuleAsync (compiler.js:34268)
at CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:239)
at PlatformRef.bootstrapModule (core.js:5578)
Run Code Online (Sandbox Code Playgroud)
app.module.ts文件
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { AppVersion } from '@ionic-native/app-version';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
AppVersion, <-- Error [[ts]
Type 'AppVersionOriginal' is not assignable to type 'Provider'.
Type 'AppVersionOriginal' is missing the following properties from type 'FactoryProvider': provide, useFactory [2322]]
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud)
更新:最后,我在这里找到了此问题的解决方案和解释:P
此问题是由于ionic新更新(释放ionic 4)引起的,您必须像这样导入ionic 3的插件:
import { PluginName} from '@ionic-native/pluginName/ngx';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
660 次 |
| 最近记录: |