各位,补发一下角度、时间进制问题。
// 小时数转换
const totwelve = (h) => {
if (h >= 0 && h < 12) return h;
if (h >= 12 && h < 24) return (h - 12);
}
const hh = document.queryselector(".hh")
const mm = document.queryselector(".mm")
const ss = document.queryselector(".ss")
const date = new date()
let hours = date.gethours()
let minutes = date.getminutes()
let seconds = date.getseconds()
// 分针角度 每分钟6度 每秒额外增加 0.1度 6/60
let minuteangle = (minutes * 6) + (seconds * 0.1)
// 时针角度 每小时30度 每分钟额外增加 0.5度 30/60
let hourangle = totwelve(hours) * 30 + (minutes * 0.5)
// 设置旋转角度
ss.style.transform = `rotate(${seconds * 6}deg)`;
mm.style.transform = `rotate(${minuteangle}deg)`;
hh.style.transform = `rotate(${hourangle}deg)`;
回复