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

相关内容

热门资讯

科普分享!wpk作弊是真的吗(... 科普分享!wpk作弊是真的吗(辅助挂)一贯有挂(有挂教学辅助软件)1、完成有辅助插件,帮助玩家取得所...
玩家交流!wepoker有没有... 玩家交流!wepoker有没有机器人(辅助挂)真是真的是有挂(有挂方法辅助工具)1、下载好脚本下载之...
揭秘攻略!约局吧游戏挂(辅助挂... 揭秘攻略!约局吧游戏挂(辅助挂)确实有挂(有挂解密辅助教程)1、这是跨平台的轻量版有透视,在线的操作...
揭秘几款!wepoker私人局... 揭秘几款!wepoker私人局辅助挂(辅助挂)本来有挂(有挂解密辅助技巧)1、金币登录送、破产送、升...
分享给玩家!wepoker轻量... 分享给玩家!wepoker轻量版透视系统(辅助挂)确实是有挂(有挂透视辅助脚本)1、玩家可以在透视最...
重大通报!aapoker怎么选... 重大通报!aapoker怎么选牌(辅助挂)切实有挂(有挂攻略辅助插件)1、许多玩家不知道辅助怎么退出...
重大来袭!wpk辅助插件(辅助... 重大来袭!wpk辅助插件(辅助挂)好像真的有挂(有挂教程辅助脚本)在进入软件靠谱后,参与本局比赛的八...
玩家必看攻略!wejoker辅... 玩家必看攻略!wejoker辅助软件价格(辅助挂)原来存在有挂(有挂细节辅助方法)1、完成有辅助插件...
玩家必看攻略!wepoker透... 玩家必看攻略!wepoker透视脚本下载(辅助挂)都是是有挂(有挂头条辅助攻略)该软件可以轻松地帮助...
科普分享!wepoker好友局... 科普分享!wepoker好友局透视(辅助挂)总是是有挂(有挂辅助辅助插件)1、实时透视辅助更新:用户...