代码之家  ›  专栏  ›  技术社区  ›  tilly

角度:向组件添加动画时组件消失

  •  1
  • tilly  · 技术社区  · 7 年前

    有人能看出我错在哪里吗?

    @Component({
        selector: 'find-locals',
        styleUrls: ['find-locals.component.css'],
        templateUrl: 'find-locals.component.html',
      animations: [
        trigger('tijl', [
          state('start', style({
            opacity: 0
          })),
          transition(':enter', [
            animate(2000)
          ])
        ])
      ]
    })
    

    <div @tijl class="header-box header-box--left">
                    <h3 class="profileSection__data">Content</h3>
                  </div>
    
    2 回复  |  直到 7 年前
        1
  •  1
  •   user184994    7 年前

    我设法使它与以下内容一起工作:

      animations: [
        trigger('tijl', [
          state('start', style({
            opacity: 0
          })),
          transition(':enter', [
            style({ opacity: '0' }),
            animate(2000)
          ])
        ])
      ]
    

    Here is a Stackblitz demo

        2
  •  0
  •   Muhammed Albarmavi    7 年前

    这边试试

    animations: [
        trigger('tijl', [
          transition(':enter', [
            style({ opacity: '0' }),
            animate(2000)
          ])
        ])
      ]
    

    动画将在2秒钟内还原样式

    stackblitz demo