darkmode ๋ง๋ค์ด๋ณด๊ธฐ
ยท
๐ฃcodeLab
const theme = localStorage.getItem('theme'); // console.log(theme); // ํ์ฌ theme๋ฅผ ์ ์ ์์. // dark || light if(theme) { document.documentElement.SetAttribute('data-theme', theme); } localStorage :: Storage ๊ฐ์ฒด๋ ๋จ์ํ key-value ์ ์ฅ์์ด๋ฉฐ, ์ด๋ ๊ฐ์ฒด์ ๋น์ทํ๋ค. ์ด ๋ฐ์ดํฐ๋ค์ ํ์ด์ง ๋ก๋ฉ์๋ ์จ์ ํ๊ฒ ์ ์ง๋๋ค. (๋ค์ ์นํ์ด์ง์ ์ ์ ํ ๋ ๋ง์ง๋ง ์ค์ ์ ๋ถ๋ฌ์ฌ ์ ์๋ค.) localStorage getItem(key) :: ํค์ ํด๋นํ๋ ๊ฐ์ ๋ฐ์์จ๋ค. setItem(key, value) :: ํค, ๊ฐ์ ๋ณด..