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

相关内容

热门资讯

透视模板!德普之星透视辅助软件... 透视模板!德普之星透视辅助软件是真的吗,德普之星透视辅助软件下载(透视)竟然是有脚本挂(哔哩哔哩)1...
透视手筋!hhpoker有透视... 透视手筋!hhpoker有透视功能吗,we-poker辅助(透视)一贯有挂(哔哩哔哩)透视手筋!hh...
透视课程!wpk免费辅助,we... 透视课程!wpk免费辅助,wepoker好友助力码(透视)果然有挂(哔哩哔哩)1、wepoker好友...
透视指南!pokemmo修改器... 透视指南!pokemmo修改器手机版,wejoker辅助器怎么卖(透视)竟然是有挂(哔哩哔哩)1、玩...
透视阶段!wepoker轻量版... 透视阶段!wepoker轻量版透视,hhpoker德州机器人(透视)其实存在有挂(哔哩哔哩)1、完成...
透视妙计!购买wepoker模... 透视妙计!购买wepoker模拟器,wpk透视辅助(透视)好像是有挂(哔哩哔哩)进入游戏-大厅左侧-...
透视办法!epoker透视底牌... 透视办法!epoker透视底牌,佛手大菠萝辅助(透视)果然真的有脚本挂(哔哩哔哩)一、佛手大菠萝辅助...
透视讲义!wpk有那种辅助吗,... 您好,wpk有那种辅助吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多...
透视办法!wepoker的辅助... 透视办法!wepoker的辅助器,cloudpoker作必弊(透视)本来有挂(哔哩哔哩)1、在wep...
透视机巧!we-poker辅助... 透视机巧!we-poker辅助,德普之星辅助器怎么用(透视)竟然真的是有挂(哔哩哔哩)1、德普之星辅...