[JavaScript] 纯文本查看 复制代码
let sum = setInterval(function(){
console.log(x);
},100);
let x=9;
steTimeout(function(){
clearInterval(sum);
},300)
[JavaScript] 纯文本查看 复制代码
<style>
body{
margin: 0;
}
.round{
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
width: 400px;
height: 400px;
border:1px solid red;
border-radius: 50%;
margin:100px auto 0;
}
.point{
width: 10px;
height: 10px;
border:1px solid blue;
border-radius: 50%;
background-color: blue;
}
</style>
<body>
<div class="round">
<div class="point"></div>
</div>
<script>
let oPoint=document.querySelector(".point");
let STEP=Math.PI/60;
let cow=0;
setInterval(function(){
oPoint.style.transform="translate("+200*Math.sin(cow)+"px,"+200*Math.cos(cow)+"px)";
cow+=STEP;
},1000/60)
</script>