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

相关内容

热门资讯

玩家亲测!老友辅助器(辅助挂)... 玩家亲测!老友辅助器(辅助挂)wepoker脚本(从来有挂);1、真人老友辅助器辅助透视,一键组局,...
盘点十款!新超凡辅助(辅助挂)... 盘点十款!新超凡辅助(辅助挂)pokeplus脚本(先前真的是有挂);1、点击下载安装,新超凡辅助插...
教程辅助!透视盒子(辅助挂)a... 教程辅助!透视盒子(辅助挂)aapoker怎么设置提高好牌几率(切实是有挂);1、当透视盒子成为包赢...
揭秘几款!四川途游防作弊(辅助... 揭秘几款!四川途游防作弊(辅助挂)hhpoker作弊码怎么用(往昔是有挂);四川途游防作弊是一项四川...
重磅来袭!广西老友玩友破解(辅... 重磅来袭!广西老友玩友破解(辅助挂)有哪些免费的wpk作弊码(一向存在有挂);一、玩家揭秘广西老友玩...
分享一款!微乐春天扑克开挂辅助... 分享一款!微乐春天扑克开挂辅助插件(辅助挂)wepoker透视有吗(真是有挂)是一款可以让一直输的玩...
免费测试版!陕西扣点点脚本辅助... 免费测试版!陕西扣点点脚本辅助器(辅助挂)wepoker私局辅助(从来真的是有挂);AI辅助机器人普...
专业讨论!皮皮辅助软件下载(辅... 专业讨论!皮皮辅助软件下载(辅助挂)pokemmo手机脚本(固有是真的有挂);1、很好的皮皮辅助软件...
揭秘几款!吉祥填大坑插件(辅助... 揭秘几款!吉祥填大坑插件(辅助挂)xpoker辅助怎么用(本然是真的有挂);是一款可以让一直输的玩家...
科普攻略!雀神挂件价格骗局(辅... 您好,雀神挂件价格骗局这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在...