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'} }
];

相关内容

热门资讯

做出回应!德扑之心免费透视,顺... 做出回应!德扑之心免费透视,顺欣茶楼怎么开挂,其实真的是有辅助神器(哔哩哔哩)1、很好的工具软件,可...
经调查!wepoker免费脚本... 经调查!wepoker免费脚本,潮友会虾蟹骰子概率计算方式,一贯是真的有辅助插件(哔哩哔哩)1、让任...
目前!hhpoker有没有作必... 目前!hhpoker有没有作必弊挂,哈糖大菠萝助手,本来有辅助app(哔哩哔哩)1、游戏颠覆性的策略...
受玩家影响!we-poker辅... 受玩家影响!we-poker辅助软件教程,微信微乐开挂,其实存在有辅助工具(哔哩哔哩)1、全新机制【...
为切实保障!hhpoker外开... 为切实保障!hhpoker外开挂靠谱吗,多乐辅助器使用方法,真是是真的有辅助工具(哔哩哔哩)1、多乐...
近年来!wepoker好友助力... 近年来!wepoker好友助力码,闲逸辅助器,原来存在有辅助app(哔哩哔哩)闲逸辅助器是不是有人用...
此事备受玩家关注!wepoke... 此事备受玩家关注!wepoker模拟器哪个,兴动互娱辅助设置步骤详解,果然是真的有辅助技巧(哔哩哔哩...
随着!cloudpoker作必... 您好,土豪联盟辅助软件下载这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很...
此事引发网友热议!pokemm... 此事引发网友热议!pokemmo脚本辅助器下载,雀神麻将辅助透视,都是真的有辅助软件(哔哩哔哩)1)...
日前!hhpoker有没有作必... 日前!hhpoker有没有作必弊辅助,天天爱游戏辅助,原来真的有辅助方法(哔哩哔哩)1、游戏颠覆性的...