ionic-framework - 在模块 ts 中输入提供程序时出错
问题描述
当我尝试import
nativepagetransition
在提供程序中时,它显示了一个错误。
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 { LinkPage } from '../pages/link/link';
import { NativePageTransitions } from '@ionic-native/native-page-transitions';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
@NgModule({
declarations: [
MyApp,
HomePage,
LinkPage,
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
LinkPage
],
providers: [
StatusBar,
SplashScreen,
NativePageTransitions,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
错误是,
Type ‘NativePageTransitionsOriginal’ is not assignable to type ‘Provider’.
Type ‘NativePageTransitionsOriginal’ is missing the following properties from type ‘FactoryProvider’: provide, useFactory [2322]]
解决方案
ionic 4+中的所有本机模块和服务已移至模块的ngx 目录。喜欢
在离子 3 中:
We were importing NativePageTransitions from @ionic-native/native-page-transitions
import { NativePageTransitions } from '@ionic-native/native-page-transitions';
现在在离子4+:
We have to import native modules from @ionic-native/module-name/ngx directory.
import { NativePageTransitions } from '@ionic-native/native-page-transitions/ngx';
推荐阅读
- python - AttributeError:类型对象“TFLiteConverterV2”没有属性“from_keras_model_file”
- hadoop - 如何通过ambari将组路由到特定的纱线队列?
- angular - 从单个堆栈栏的每个部分获取单击的对象,因为我的堆栈栏有多个部分 Chart.js
- android - 如何在 android studio 中使用 .tflite 模型进行图像分类
- c++ - Cmake:为 MSVC (Visual C++) 分别设置 C 和 C++ 代码的警告级别
- swagger - 如何在 OpenAPI 2.0 中定义像“2020 年 1 月 22 日”这样的日期?
- cloudflare-apps - 如何根据 js 对象更新 CloudFlare App 中的下拉列表?
- javascript - 为大于 2KB 的键创建索引
- javascript - navigator.mediaDevices.getUserMedia 在桌面和 Android 上运行良好,但在 IOS 移动设备上抛出错误
- ansible-2.x - 通过 ansible2.9 自动化 JX 安装过程