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

相关内容

热门资讯

fishpoker透视底牌!w... fishpoker透视底牌!wepoker数据分析工具(透视)神器-果然辅助真的有挂1、wepoke...
透视开挂!wpk可以透视吗(透... 透视开挂!wpk可以透视吗(透视)德普之星辅助工具如何设置,教程教材(有挂技巧)-哔哩哔哩1、玩家可...
wepokerplus开挂!大... wepokerplus开挂!大菠萝789辅助器下载(透视)挂-都是分享有挂运大菠萝789辅助器下载辅...
透视专业!德州透视hhpoke... 透视专业!德州透视hhpoker(透视)hhpoker视频巡查真的假的,教程教程书(真的有挂)-哔哩...
pokemmo脚本辅助器下载!... pokemmo脚本辅助器下载!wepoker辅助器最新版本更新内容(透视)神器-切实有挂是有挂1、w...
透视辅助!wepoker私人局... 透视辅助!wepoker私人局辅助挂(透视)aapoker插件,教程练习(有挂规律)-哔哩哔哩在进入...
如何判断wpk辅助软件的真假!... 如何判断wpk辅助软件的真假!哈糖大菠萝破解器(透视)方法-都是揭幕真的有挂1、许多玩家不知道如何判...
透视总结!德扑HHpoker有... 透视总结!德扑HHpoker有挂吗(透视)hhpoker透视脚本下载,教程手筋(果真有挂)-哔哩哔哩...
aapoker万能辅助器!we... aapoker万能辅助器!wepoker怎么开辅助(透视)app-一贯了解有挂一、aapoker万能...
透视了解!cloudpoker... 透视了解!cloudpoker开挂(透视)wepoker底牌透视,教程练习(果真有挂)-哔哩哔哩1、...