1 实现一个简单的动画

  1. html页面
  2. <div class="content">
  3. <button (click)="showaside()">弹出侧边栏</button>
  4. <button (click)="hiddenaside()">隐藏侧边栏</button>
  5. </div>
  6. <aside id="aside">
  7. 侧边栏
  8. </aside>
  9. ts页面
  10. import { Component, OnInit } from '@angular/core';
  11. @Component({
  12. selector: 'app-aniamations',
  13. templateUrl: './aniamations.component.html',
  14. styleUrls: ['./aniamations.component.less']
  15. })
  16. export class AniamationsComponent implements OnInit {
  17. constructor() { }
  18. ngOnInit() {
  19. }
  20. showaside(){
  21. let asideDom:any = document.getElementById('aside')
  22. asideDom.style.transform = 'translateX(0)'
  23. }
  24. hiddenaside(){
  25. let asideDom:any = document.getElementById('aside')
  26. asideDom.style.transform = 'translateX(100%)'
  27. }
  28. }