【问题标题】:Im geting this error trying to make an import on IONIC我尝试在 IONIC 上进行导入时遇到此错误
【发布时间】:2019-06-28 02:45:49
【问题描述】:

我正在尝试导入“InAppBrowser”插件以在 Android 应用中显示 WordPress 网站。

当我尝试编译代码时出现此错误

[ng] src/app/app.module.ts(19,5) 中的错误:错误 TS2322:类型 'InAppBrowserOriginal' 不可分配给类型 'Provider'。 [ng]
类型“InAppBrowserOriginal”不可分配给类型“ClassProvider”。 [ng] 类型“InAppBrowserOriginal”中缺少属性“provide”。 [ng] [ng] i 「wdm」: 编译失败。

这是我的 app.module.ts 上的代码

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } 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 { InAppBrowser } from '@ionic-native/in-app-browser';

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

【问题讨论】:

  • 能否请您导入以下行而不是您的: import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';

标签: angular ionic-framework ionic4


【解决方案1】:

这是一个 Ionic 4 项目吗? 如果是这样,正确的导入是

import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';

docs中解释。

请注意,其他导入已经使用 /ngx 后缀(来自 Ionic 4)。

【讨论】:

    猜你喜欢
    • 2022-10-16
    • 2019-02-23
    • 2023-01-01
    • 2020-07-06
    • 2022-12-30
    • 2020-07-05
    • 2020-08-15
    • 2021-06-21
    • 2018-09-02
    相关资源
    最近更新 更多