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

相关内容

热门资讯

wepoke真的有挂!德州wp... wepoke真的有挂!德州wpk德州真的,(WepOke)固有真的有挂(详细透视透明教程);wepo...
wepoke确实有挂!wpk透... 1、wepoke确实有挂!wpk透视辅助可测试,(aApoker)最初存在有挂(详细辅助玩家教程);...
微扑克ai辅助器苹果版!德扑之... 微扑克ai辅助器苹果版!德扑之星能看到底牌吗,(wEpoKe)往昔有挂(详细透视2025新版总结);...
透视工具(微扑克ai机器人)w... 透视工具(微扑克ai机器人)wpk微扑克智能辅助(详细辅助必胜教程)先前真的是有挂1、超多福利:超高...
透视插件(wepoke有没有挂... 透视插件(wepoke有没有挂)智星德州扑克辅牌器(详细辅助AI教程)一向有挂1)辅助挂:进一步探索...
德州之星辅助挂!德州数据辅助器... 德州之星辅助挂!德州数据辅助器,(AAPOKEr)确实真的是有挂(详细透视新版2025教程) 科技详...
智星德州菠萝偷偷看牌功能!aa... 智星德州菠萝偷偷看牌功能!aapoker安卓怎么下载,(wpK)一向真的是有挂(详细透视线上教程);...
透视教学(aapoker有猫腻... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在这款游戏中打牌都...
WePoKe外挂!德州ai智能... 1、WePoKe外挂!德州ai智能辅助,(wEPoke)竟然是有挂(详细透视教你攻略)。2、WePo...
透视app(德州AI智能辅助机... 透视app(德州AI智能辅助机器人)微扑克有挂吗(详细辅助必胜教程)原先有挂;一、AI软件牌型概率发...