Angular路由转换动画报错(缺少模块)
创始人
2024-10-28 06:00:48
0
  1. 确认是否安装了 @angular/animations 模块,如果没有安装则需要安装它。

  2. 在 app.module.ts 文件中导入 BrowserAnimationsModule 并将其添加到 imports 数组中:

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
// ...
@NgModule({
  imports: [
    // ...
    BrowserAnimationsModule
  ],
  // ...
})
export class AppModule { }
  1. 在路由组件中添加动画代码,例如:
import { Component } from '@angular/core';
import {
  trigger,
  transition,
  style,
  animate,
  query,
  stagger
} from '@angular/animations';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
  animations: [
    trigger('routeAnimations', [
      transition('* <=> *', [
        query(':enter, :leave', [
          style({
            position: 'absoulte',
            left: 0,
            width: '100%'
          })
        ]),
        query(':enter', [
          style({left: '-100%'})
        ]),
        query(':leave', animate('300ms ease-out', style({left: '100%'}))),
        query(':enter', animate('300ms ease-out', style({left: '0%'})))
      ])
    ])
  ]
})
export class AppComponent {
}
  1. 确认路由组件中使用了以下属性:

  1. 通过在路由定义中添加 data 属性来指定动画名称,例如:
const routes: Routes = [
  { path: '', component: HomeComponent, data: {animation: 'home'} },
  { path: 'about', component: AboutComponent, data: {animation: 'about'} },
  { path: 'contact', component: ContactComponent, data: {animation: 'contact'} }
];

相关内容

热门资讯

透视数据"hhpok... 透视数据"hhpoker外挂靠谱吗"详细辅助专业教程(有透视功能技巧)是由北京得hhpoker外挂靠...
辅助透视"wepok... 辅助透视"wepoker可以免费玩吗"详细辅助安装教程(透视脚本免费下载pc软件);1.wepoke...
透视免费"大菠萝免费... 透视免费"大菠萝免费辅助"详细辅助2025新版教程(透视脚本苹果版技巧)是一款可以让一直输的玩家,快...
透视透视"hh po... 透视透视"hh poker辅助器先试用"详细辅助必赢教程(透视底牌攻略),支持语音通讯、好友开房及战...
透视新版"werpl... 透视新版"werplan有挂吗"详细辅助介绍教程(透视脚本免费软件)是由北京得werplan有挂吗黑...
透视挂"wepoke... 透视挂"wepoker辅助软件视频"详细辅助微扑克教程(透视辅助下载技巧);建议优先通过wepoke...
透视智能ai"wep... 透视智能ai"wepoker破解游戏盒子"详细辅助必备教程(俱乐部辅助透视)准备好在wepoker破...
透视代打"wepok... 透视代打"wepoker怎么拿到好牌"详细辅助透视教程(透视底牌方法);《WPK辅助透视》‌:支持手...
透视神器"来玩app... 透视神器"来玩app破解"详细辅助德州论坛(破解是真的还是假的神器);最新版2024是一款经典耐玩的...
透视真的"拱趴游戏破... 这是一款非常优秀的拱趴游戏破解器 ia辅助检测软件,能够让你了解到拱趴游戏破解器中牌率当中全部隐藏参...