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

相关内容

热门资讯

透视总结!aapoker真的假... 透视总结!aapoker真的假的(WePoKer大神)果然真的是有辅助工具(哔哩哔哩)透视总结!aa...
透视了解!微乐小程序黑科技免费... 透视了解!微乐小程序黑科技免费,陕西微乐小程序修改器(透视)其实有辅助软件(哔哩哔哩)该软件可以轻松...
透视办法!来玩app破解版(W... 透视办法!来玩app破解版(WePoKer破解版)真是是真的有辅助技巧(哔哩哔哩)小薇(辅助器软件下...
随着!微乐小程序黑科技,微乐四... 随着!微乐小程序黑科技,微乐四川麻将辅助器(透视)竟然存在有辅助软件(哔哩哔哩)1、免费辅助多个强度...
透视模板!约局吧是否有挂(We... 透视模板!约局吧是否有挂(WePoKer内容)总是存在有辅助教程(哔哩哔哩)1、每一步都需要思考,不...
透视妙计!拱趴游戏破解器(We... 透视妙计!拱趴游戏破解器(WePoKer破解版)好像是真的有辅助技巧(哔哩哔哩)1、全新机制【拱趴游...
透视经验!佛手在线有挂吗(We... 透视经验!佛手在线有挂吗(WePoKer正规)竟然真的有辅助插件(哔哩哔哩)1、不需要AI权限,帮助...
透视步骤!wepoker私人局... 透视步骤!wepoker私人局透视插件(WePoKer辅助器)其实存在有辅助方法(哔哩哔哩);1、超...
透视讲义!哈糖大菠萝破解器(德... 您好,哈糖大菠萝破解器这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩...
透视窍门!wepoker私局辅... 透视窍门!wepoker私局辅助(WePoKer视频)竟然是真的有辅助攻略(哔哩哔哩)1、打开软件启...