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透明挂辅助!wpk... wepoke透明挂辅助!wpk胜率跟号有关么,鱼扑克软件辅助,wpk教程(总是存在有挂);最新版20...
黑科技透明挂!(wePokE)... 黑科技透明挂!(wePokE)软件透明挂,(wepoker)切实是有挂,必备教程(有挂透视);支持2...
wpk德州ai辅助神器!wpk... wpk德州ai辅助神器!wpk德州职业代打,德扑之星作弊,实用技巧(素来是真的有挂);实战中需综合运...
黑科技数据!(wepokE)软... 1、黑科技数据!(wepokE)软件透明挂,(WEPOke)一贯存在有挂,AI教程(有挂技巧)2、进...
wepoke怎么看有没有外挂!... wepoke怎么看有没有外挂!扑克时间假不假,wpk透视辅助器,玩家教程(从前是有挂);玩家必备必赢...
黑科技软件!(wEPOKE)软... 1、黑科技软件!(wEPOKE)软件透明挂,(Wepoke)总是是真的有挂,2025新版教程(有挂透...
德州ai机器人!微扑克有规律吗... 1、德州ai机器人!微扑克有规律吗,德扑ai开发,第三方教程(起初真的有挂)。2、微扑克有规律吗透视...
黑科技实锤!(wPK)透视辅助... 您好,wPK这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在这款游戏中...
wepoke用模拟器!poke... 此外,数据分析德州(扑克时间假不假)辅助神器app还具备辅助透视行为开挂功能,通过对客户扑克时间假不...
黑科技计算!(德州ai)外挂辅... 黑科技计算!(德州ai)外挂辅助工具,(德州ai)往昔真的是有挂,我来教教你(有挂教程);科技安装教...