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、佛手...
围绕透视问题!aapoker免... 围绕透视问题!aapoker免费透视脚本(透视)一起宁德钓蟹辅助怎么设置(果然是有辅助插件)-哔哩哔...
透视演示!哈糖大菠萝可以开挂吗... 透视演示!哈糖大菠萝可以开挂吗(透视)xpoker辅助工具(辅助)本来真的是有工具(哔哩哔哩)1、许...
昨日!sohoopoker辅助... 昨日!sohoopoker辅助(透视)越乡游义乌辅助器免费(一直是真的辅助修改器)-哔哩哔哩昨日!s...
透视经验!约局吧游戏挂(透视)... 透视经验!约局吧游戏挂(透视)agpoker辅助(辅助)一贯有app(哔哩哔哩)1、约局吧游戏挂破解...
透视代打!aapoker真的假... 透视代打!aapoker真的假的(透视)哥哥打大a有辅助吗(竟然真的有辅助辅助器)-哔哩哔哩1、该软...
透视资料!德州局透视脚本(透视... 透视资料!德州局透视脚本(透视)大菠萝789辅助器下载(辅助)竟然是真的有工具(哔哩哔哩)1、大菠萝...
据公告内容!wepoker透视... 据公告内容!wepoker透视辅助下载(透视)欢乐达人猜猜乐辅助(一贯真的有辅助软件)-哔哩哔哩1、...
透视攻略!fishpoker透... 透视攻略!fishpoker透视底牌(透视)约局吧怎么看有没有挂(辅助)一直真的有app(哔哩哔哩)...
目前!wpk辅助购买(透视)途... 您好,途游手游辅助这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩家在...