首页 > 解决方案 > 页面不使用动画 ionic3 过渡

问题描述

我试图通过向前动画页面从主页导航到聊天页面,但页面总是从底部弹出,我的代码是

goTochat(friendId){
    this.provider.setUser(friendId);
    setTimeout(() => {
        this.navCtrl.push(ChatPage, {}, { animate: true, direction: 'forward' });
    },20)
}

我哪里错了!请帮忙!

标签: ionic3

解决方案


您是否在 Android 设备上进行测试?我认为这是默认动画。

如果要指定页面转换,可以使用: https ://ionicframework.com/docs/native/native-page-transitions/

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

constructor(private nativePageTransitions: NativePageTransitions) { }

...


// example of adding a transition when a page/modal closes
ionViewWillLeave() {

 let options: NativeTransitionOptions = {
    direction: 'up',
    duration: 500,
    slowdownfactor: 3,
    slidePixels: 20,
    iosdelay: 100,
    androiddelay: 150,
    fixedPixelsTop: 0,
    fixedPixelsBottom: 60
   };

 this.nativePageTransitions.slide(options)
   .then(onSuccess)
   .catch(onError);

}


// example of adding a transition when pushing a new page
openPage(page: any) {

  this.nativePageTransitions.slide(options);
  this.navCtrl.push(page);

}

推荐阅读