我正在尝试进行淡入淡出过渡以进行页面过渡。我已经安装了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
答案 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",
希望这会有所帮助!