站内搜索:
首页 >> 前端 >> 内容
动态样式绑定定时器解析

时间:2018/1/22 16:34:08

demo.component.ts

动态样式绑定定时器解析。

import { Component, OnInit, OnDestroy } from '@angular/core';

@Component({
    selector: 'demo10',
    template:`
        

精彩

` }) export class Demo10Component implements OnInit { myOpacityValue=0; myTimer:any=null; constructor() { } ngOnInit() { this.myTimer=setInterval(()=>{ this.myOpacityValue+=0.1; //console.log(this.myOpacityValue); if(this.myOpacityValue>1){ //必须大于1,因为js在1处有误差,不准确 this.myOpacityValue=0; } },500); } ngOnDestroy() { this.myTimer=null; clearInterval(this.myTimer); } }

  • 上一篇:puppeteer新手入门(chromium下载跳坑)
  • 下一篇:CSS3filter与opacity解析
  • 返回顶部