在安装 cordova-plugin-advanced-http 插件后,当我尝试将其导入app.modules.ts中的提供程序时,我得到以下信息:
我已经重新安装,清理了缓存,并且这种情况一直在发生。这是app.module.ts代码:
import { HTTP } from '@ionic-native/http';
import { GalleryPageModule } from './../pages/gallery/gallery.module';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
//providers
import { ImagesProvider } from '../providers/images/images';
//plugins
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { File } from '@ionic-native/file';
import { FileTransfer } from "@ionic-native/file-transfer";
import { AndroidPermissions } from '@ionic-native/android-permissions';
import { SocialSharing } from '@ionic-native/social-sharing';
//firebase
import { firebase } from './../firebase';
import { AngularFireModule } from '@angular/fire';
import { AngularFireDatabaseModule, AngularFireDatabase } from '@angular/fire/database';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { AngularFirestoreModule, AngularFirestore } from '@angular/fire/firestore';
import { ImagenPageModule } from '../pages/imagen/imagen.module';
@NgModule({
declarations: [
MyApp,
HomePage,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
HttpClientModule,
GalleryPageModule,
AngularFireModule.initializeApp(firebase),
AngularFireDatabaseModule,
AngularFireAuthModule,
AngularFirestoreModule.enablePersistence(),
ImagenPageModule,
GalleryPageModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
HttpClient,
ImagesProvider,
AngularFirestore,
File,
HTTP,
FileTransfer,
AndroidPermissions,
SocialSharing,
]
})
export class AppModule {}
我已经尝试过在其他项目中使用它,并且它起作用了,但并没有出现 HTTPOriginal 建议。
答案 0 :(得分:5)
您安装了最新的@ionic-native/http
测试版(v5 +)
您必须从HTTP
导入/ngx
import { HTTP } from '@ionic-native/http/ngx';
否则将退回到@ionic-native/http
v4 +
答案 1 :(得分:0)
这是因为Ionic已更新了所有插件,所以我建议使用该插件的较低版本。如果您当前使用的是4.5.0或更高版本,则必须使用4.3.2或更低版本降级。
答案 2 :(得分:0)
在@ionic-native/android-permissions
的情况下,我也遇到了相同的错误。
要解决此类问题,只需降级插件的版本。
示例:
@ionic-native/android-permissions@.5.0.1
到 @ionic-native/android-permissions@3.4.0