如下所示:
loadingTimer(){ clearInterval(this.$el.loading_timer); const rotate_angle=30,speed=90; this.$el.loading_timer=setInterval(()=>{ const rotate_el=this.$el.querySelector('.rotate'); /*获得当前元素是transform值*/ let origin_angle=rotate_el.style.transform; if(origin_angle){ origin_angle=Number.parseInt(origin_angle.replace(/[^0-9]/ig,'')); }else{ origin_angle=rotate_angle; }; rotate_el.style.transform=`rotate(${origin_angle+rotate_angle}deg)`; console.log(1231264); },speed) }
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!