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

相关内容

热门资讯

普及知识!wepoker如何设... 普及知识!wepoker如何设置透视,wepoker智能辅助插件,一直真的有挂(今日头条)1、该软件...
玩家必用!hhpoker辅助器... 玩家必用!hhpoker辅助器视频,wepoker怎么增加运气,果然是有挂(确实有挂)破解侠是真的助...
科技介绍!德普之星透视辅助插件... 科技介绍!德普之星透视辅助插件,wepoker私人局辅助挂,总是有挂(有挂秘笈)1、起透看视 辅助软...
攻略讲解!来玩app破解版,p... 攻略讲解!来玩app破解版,pokerworld辅助器,确实是有挂(有挂透视)1、起透看视 辅助软件...
一分钟教会你!steampok... 一分钟教会你!steampokermaster辅助,wepoker安装教程,确实有挂(证实有挂)1、...
玩家必看!佛手在线是不是有挂,... 玩家必看!佛手在线是不是有挂,德州辅助工具到底怎么样,一直是真的有挂(揭秘有挂)1、很好的工具软件,...
热点推荐!菠萝辅助器免费版的特... 热点推荐!菠萝辅助器免费版的特点,we-poker软件,真是真的有挂(有挂头条)1、下载好菠萝辅助器...
科技新动态!云扑克有透视吗,p... 科技新动态!云扑克有透视吗,pokemmo脚本,真是有挂(今日头条)1、破解器简单,机器人操作,插件...
总算了解!微扑克游戏辅助器,德... 总算了解!微扑克游戏辅助器,德普之星透视辅助软件激活码,竟然是真的有挂(有挂功能)1、每一步都需要思...
科技介绍!智星德州可以透视吗,... 科技介绍!智星德州可以透视吗,德州局脚本,本来是真的有挂(的确有挂)1、操作简单,无需手机版透视脚本...