cordova - ionic 4 Cordova cordova-plugin-facebook4 : Property 'provide' is missing in type 'FacebookOriginal'

标签 cordova angular6 ionic4

我在使用 Ionic 4、Cordova、Angular6 应用程序时遇到问题。 安装 cordova-plugin-facebook4 并将其添加到 app.module.ts 文件后,TS 编译器会生成以下错误:

[ng] ℹ 「wdm」: Compiled successfully.
[ng] ERROR in src/app/app.module.ts(13,11): error TS2345: Argument of type '{ declarations: (typeof AppComponent)[]; entryComponents: undefined[]; imports: (ModuleWithProvid...' is not assignable to parameter of type 'NgModule'.
[ng]   Types of property 'providers' are incompatible.
[ng]     Type '(typeof SplashScreen | FacebookOriginal | { provide: typeof RouteReuseStrategy; useClass: typeof ...' is not assignable to type 'Provider[]'.
[ng]       Type 'typeof SplashScreen | FacebookOriginal | { provide: typeof RouteReuseStrategy; useClass: typeof I...' is not assignable to type 'Provider'.
[ng]         Type 'FacebookOriginal' is not assignable to type 'Provider'.
[ng]           Type 'FacebookOriginal' is not assignable to type 'ClassProvider'.
[ng]             Property 'provide' is missing in type 'FacebookOriginal'.

This is my configuration:

✔ Gathering environment info - done!

Ionic:

   ionic (Ionic CLI)          : 4.1.2 (/usr/lib/node_modules/ionic)
   Ionic Framework            : @ionic/angular 4.0.0-beta.7
   @angular-devkit/core       : 0.7.5
   @angular-devkit/schematics : 0.7.5
   @angular/cli               : 6.1.5
   @ionic/ng-toolkit          : 1.0.8
   @ionic/schematics-angular  : 1.0.6

Cordova:

   cordova (Cordova CLI) : 8.1.1 (cordova-lib@8.1.0)
   Cordova Platforms     : android 7.1.1
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 4 other plugins)

这是app.module.ts:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule, RouteReuseStrategy, Routes } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { Facebook } from '@ionic-native/facebook';

@NgModule({
  declarations: [AppComponent],
  entryComponents: [],
  imports: [
    BrowserModule,
    IonicModule.forRoot(),
    AppRoutingModule
  ],
  providers: [
    StatusBar,
    SplashScreen,
    Facebook,
    { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

此软件包也已安装并在 package.json 文件中可用:

"@ionic-native/facebook": "^4.15.0"

预先感谢您的意见。

最佳答案

我设法弄清楚了这一点: 应该从 ionic-native Facebook 模块的“ngx”文件夹中完成包含,如下所示:

从'@ionic-native/facebook/ngx'导入{Facebook};

该模块的任何文档中均未提供此信息。

关于cordova - ionic 4 Cordova cordova-plugin-facebook4 : Property 'provide' is missing in type 'FacebookOriginal' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52668361/

相关文章:

javascript - ionic 上传错误 : advanced-http: "params" option needs to be an dictionary style object, <params: {[key: string]: string |字符串[]}>

javascript - 使用 JavaScript/HTML/CSS 开发 OSX 应用程序

android - ionic POST 请求错误,net::ERR_CONNECTION_REFUSED

Angular 6 - 翻译动态文本

typescript - 类型 'IterableIterator<[number, any]>' 不是数组类型或字符串类型

angular - Ion-slides 不更新动态数据

ios - Phonegap - 手机锁定时播放本地音频 iOS 6

angular6 - 如何在ng2-smart-table的下拉菜单中设置多项选择?

angular - 如何在 Angular 6 应用程序中使用 React 组件

angular - 使用 Angular 7 处理 HTTPErrorResponse 的最佳方式