离子错误对象(...)不是NativePageTransitions.fade上的函数

时间:2019-02-07 12:32:37

标签: javascript cordova npm ionic3 ionic4

我正在尝试进行淡入淡出过渡以进行页面过渡。我已经安装了native-page-transition plugin测试版。

$ ionic cordova plugin add com.telerik.plugins.nativepagetransitions
$ npm install @ionic-native/native-page-transitions@beta

,并在app.module.ts中添加了提供程序

import { NativePageTransitions } from '@ionic-native/native-page-transitions/ngx';

providers: [
    NativePageTransitions,
]

在页面中,我将其用作

import { NativePageTransitions, NativeTransitionOptions } from '@ionic-native/native-page-transitions/ngx';

constructor(private nativePageTransitions: NativePageTransitions){}

Animation(){
    let options: NativeTransitionOptions = {}
    this.nativePageTransitions.fade(options);
    this.navCtrl.setRoot(HomePage);
  }

但是当我运行脚本并运行函数时,它显示了以下错误

  

TypeError:Object(...)不是函数       在NativePageTransitions.fade

请帮助我摆脱错误。

离子信息

Ionic:

   ionic (Ionic CLI)  : 4.10.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.1

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 6.4.0, browser 5.0.4, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, (and 12 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/user/Library/Android/sdk)
   ios-deploy        : 1.9.4
   NodeJS            : v10.15.0 (/usr/local/bin/node)
   npm               : 6.4.1
   OS                : macOS Mojave
   Xcode             : Xcode 10.1 Build version 10B61

1 个答案:

答案 0 :(得分:1)

是因为@ionic-native/native-page-transitions

的版本

确保您的@ionic-native/native-page-transitions版本与@ionic/native/core相同

package.json

之前

"@ionic-native/core": "~4.20.0",
"@ionic-native/native-page-transitions": "^5.13.0",
"@ionic-native/splash-screen": "~4.20.0",
"@ionic-native/status-bar": "~4.20.0",

之后

"@ionic-native/core": "~4.20.0",
"@ionic-native/native-page-transitions": "^4.20.0",
"@ionic-native/splash-screen": "~4.20.0",
"@ionic-native/status-bar": "~4.20.0",

希望这会有所帮助!