QQ群招募中:646258285(招募中,没几个人说话),
需要交流的朋友可以直接加我微信( DntBeliv )或QQ( 1121864253 )
注意setTimeout是异步执行的,因此需要用递归的办法实现
const TIME0_in = 800 //ms
const TIME_delay = 40 //ms
const opacityDelay = TIME_delay/TIME0_in
let that = this
let i = 0;
function changeOpacity(){
if(i>=TIME0_in/TIME_delay){
console.log("2")
this.opacity = 1
return ;
}
that.opacity = 1-opacityDelay*i
setTimeout(()=>{
changeOpacity()
},TIME_delay)
i++
console.log("1")
}
changeOpacity()