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

相关内容

热门资讯

经核实!红龙poker辅助器免... 经核实!红龙poker辅助器免费观看,德普之星透视软件免费入口官网,确实真的有挂(真的有挂)德普之星...
总算明白!wepoker安装教... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...
截至发稿!哈糖大菠萝能开挂吗,... 截至发稿!哈糖大菠萝能开挂吗,智星菠萝透视,好像存在有挂(有挂方针)1、智星菠萝透视免费脚本咨询教程...
最新技巧!wepoker是不是... 最新技巧!wepoker是不是有人用挂,wepoker底牌透视,果然真的有挂(有人有挂)运辅助工具,...
备受关注的!impoker辅助... 备受关注的!impoker辅助,德普之星怎么开辅助,总是真的有挂(有挂技巧)1、实时德普之星怎么开辅...
重大发现!wepoker好友助... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在这款游戏中打...
此事迅速冲上热搜!wepoke... 此事迅速冲上热搜!wepoker透视脚本免费app,德普之星透视辅助软件是真的吗,切实真的有挂(有挂...
大神推荐!wepoker网页版... 大神推荐!wepoker网页版透视方法,wepoker-h5下载,竟然是有挂(有挂猫腻)辅助器是一种...
针对!wepoker私人局外卦... 针对!wepoker私人局外卦,德普之星透视辅助软件是真的吗,本来真的是有挂(果真有挂)1、每一步都...
总算清楚!wepoker免费透... 总算清楚!wepoker免费透视脚本,约局吧透视挂下载,都是是有挂(有挂实锤)1、任何wepoker...