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工具!德州扑克神器辅助a... WPK工具!德州扑克神器辅助ai,约局吧如何查看是否有挂,真是是有ai辅助模板1、下载好约局吧如何查...
WPK四人!WePoKer工具... WPK四人!WePoKer工具辅助ai,约局吧透视挂下载,竟然有ai辅助绝活儿1、完成约局吧透视挂下...
WPK软件!智星菠萝德州神器开... WPK软件!智星菠萝德州神器开挂ai,德扑之星透视辅助软件,都是存在有ai开挂方针1、德扑之星透视辅...
WPK德州局!红龙PoKer技... WPK德州局!红龙PoKer技巧透视挂ai,aapoker怎么控制牌,都是是有ai透视挂绝活儿1、操...
WPK四人!aapoker方法... WPK四人!aapoker方法开挂ai,AApoker脚本,一直真的有ai开挂教材AApoker脚本...
WPK多开!WePoKer方法... WPK多开!WePoKer方法辅助ai,德普之星私人局辅助免费,其实是有ai辅助课程1、德普之星私人...
WPK脚本!WPK工具辅助ai... WPK脚本!WPK工具辅助ai,约局吧开挂,确实真的是有ai辅助步骤1、进入游戏-大厅左侧-新手福利...
WPK俱乐部!WePoKer攻... WPK俱乐部!WePoKer攻略透视ai,拱趴大菠萝十三水作弊,好像是有ai透视操作1、让任何用户在...
WPK控制牌!WePoKer神... WPK控制牌!WePoKer神器开挂ai,德普之星透视辅助插件,竟然真的是有ai开挂窍要德普之星透视...
WPK工具!微扑克app辅助a... WPK工具!微扑克app辅助ai,AApoker逻辑,都是有ai辅助策略1、完成AApoker逻辑有...