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私人局辅助是真的吗,wepoker辅助器官方(透视)有挂教程(存在有挂)-哔哩哔哩所...
透视免费!wepoker破解版... 透视免费!wepoker破解版内购,hhpoker到底可以辅助码(透视)专业教程(有挂方针)-哔哩哔...
透视科技!拱趴大菠萝万能挂图解... 透视科技!拱趴大菠萝万能挂图解,hhpoker怎么开透视(透视)分享教程(真实有挂)-哔哩哔哩1)拱...
透视透视挂!拱趴大菠萝辅助神器... 透视透视挂!拱趴大菠萝辅助神器,红龙poker有辅助吗(透视)必备教程(有挂功能)-哔哩哔哩1、完成...
透视能赢!德普之星辅助工具如何... 透视能赢!德普之星辅助工具如何设置,约局吧是否有挂(透视)必备教程(有挂教学)-哔哩哔哩1)德普之星...
刚刚!wepoker辅助器软件... 刚刚!wepoker辅助器软件下载,wepoker私人局怎么玩(透视)解密教程(有挂规律)-哔哩哔哩...
受玩家影响!佛手在线大菠萝为什... 受玩家影响!佛手在线大菠萝为什么都输,pokemmo免费脚本(透视)总结教程(有挂透明挂)-哔哩哔哩...
透视好牌!wepoker祈福有... 透视好牌!wepoker祈福有用吗,wepoker公共底牌(透视)辅助教程(确实有挂)-哔哩哔哩1、...
出现新变化!hhpoker到底... 出现新变化!hhpoker到底可以辅助码,hhpoker为什么一直输(透视)揭幕教程(真是有挂)-哔...
透视教程!德普之星透视辅助,s... 透视教程!德普之星透视辅助,sohoopoker辅助(透视)揭露教程(讲解有挂)-哔哩哔哩1)德普之...