简要教程
【案例简介】
本项目是基于js实现的统计模式。可以通过点击模式 进行切换。下面是具体的界面效果和操作方式。欢迎下载使用。
【案例截图】
【核心代码】
const checkbox = document.querySelector('#checkbox')
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
checkbox.setAttribute('checked', true)
}
checkbox.addEventListener('change', function (event) {
if (this.checked) {
document.body.classList.remove('is-light-mode')
document.body.classList.add('is-dark-mode')
} else {
document.body.classList.remove('is-dark-mode')
document.body.classList.add('is-light-mode')
}
})





