๐ช Programming
[TS] ํ์
์คํฌ๋ฆฝํธ - ๊ธฐ์ด ๋ด์ฉ ์ ๋ฆฌ
[TS] ํ์ ์คํฌ๋ฆฝํธ - ๊ธฐ์ด ๋ด์ฉ ์ ๋ฆฌ
2024.04.24ํ์
์คํฌ๋ฆฝํธ๋?ํ์
์คํฌ๋ฆฝํธ๋ ์๋ฐ์คํฌ๋ฆฝํธ์ ํ์
์ ๋ถ์ฌํ ์ธ์ด๋ค. ์๋ฐ์คํฌ๋ฆฝํธ์ ํ์ฅ๋ ์ธ์ด๋ผ๊ณ ๋ณผ ์ ์๋ค. ํ์
์คํฌ๋ฆฝํธ๋ฅผ ๋ธ๋ผ์ฐ์ ์์ ์คํํ๋ ค๋ฉด ํ์ผ์ ํ ๋ฒ ๋ณํํด์ค์ผ ํ๋ค. ์ด ๋ณํ ๊ณผ์ ์ ์ปดํ์ผ(์ ํํ๋ ํธ๋์คํ์ผ๋ง)์ด๋ผ๊ณ ๋ถ๋ฅธ๋ค.์ฐธ๊ณ ๋ก Babel์ ์๋ฐ์คํฌ๋ฆฝํธ์ ์ต์ ๋ฌธ๋ฒ์ ์ต๋ํ ๋ง์ ๋ธ๋ผ์ฐ์ ์์ ํธํํ ์ ์๋๋ก ๋ณํํด์ฃผ๋ ๋๊ตฌ๋ค. ์ ์จ์ผ ํ ๊น?์๋ 2๊ฐ์ง ๊ด์ ์์ JS ์ฝ๋ ํ์ง๊ณผ ๊ฐ๋ฐ ์์ฐ์ฑ์ ๋์ผ ์ ์๋ค.์๋ฌ ์ฌ์ ๋ฐฉ์ง์ฝ๋ ๊ฐ์ด๋ ๋ฐ ์๋ ์์ฑ(์์ฐ์ฑ ํฅ์) ์๋ฌ ์ฌ์ ๋ฐฉ์ง์๋ ๋ ์ฝ๋ ๋ชจ๋ ๋ ์ซ์์ ํฉ์ ๊ตฌํ๋ ํจ์๋ค. ์๋ ์๋ฐ์คํฌ๋ฆฝํธ, ์๋๋ ํ์
์คํฌ๋ฆฝํธ๋ก ์์ฑํ๋ค. ํจ์ ํธ์ถ ์ ์ซ์๊ฐ ์๋ ๋ฌธ์์ด์ ๋ฃ์ผ๋ฉด ์๋ฐ์คํฌ๋ฆฝํธ๋ ๋ฌธ์์ด์ ๊ฒฐํฉํด์ ์ ํ ๋ค๋ฅธ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ค. ์๋..
[JS] location ๊ฐ์ฒด์ href/assign, replace ์ฐจ์ด์
[JS] location ๊ฐ์ฒด์ href/assign, replace ์ฐจ์ด์
2024.04.24์ฐจ์ด์ ์์ฝwindow.location.assign(๋ฐ href) : ์ ๋ณด๋ฅผ ์ ์กํ์ง ์๊ณ ํ์ด์ง๋ง ์ด๋ / ๋ค๋ก ๊ฐ๊ธฐ ๊ฐ๋ฅwindow.location.replace : ์ ๋ณด๋ฅผ ์ ์กํ์ง ์๊ณ ํ์ด์ง๋ง ๊ต์ฒด / ๋ค๋ก ๊ฐ๊ธฐ ๋ถ๊ฐwindow.location.reload : ํ์ฌ ํ์ด์ง์ ๋ฌธ์ ๋ค์ ๋ก๋ window.location.assign (href)๋ค๋ก ๊ฐ๊ธฐ ๋ฒํผ์ ๋๋ฌ ์ด์ ํ์ด์ง๋ก ์ด๋ํ ์ ์๋ค์ฃผ์ ํ์คํ ๋ฆฌ์ ๊ธฐ๋ก๋๋ค๋ค๋ก ๊ฐ๊ธฐ : location.assign ๋ฉ์๋๋ฅผ ํธ์ถํ ํ์ด์ง๋ก ์ด๋์ฉ๋ : URL์ ์ด๋ํ๋ ๋๋ถ๋ถ์ ๊ฒฝ์ฐ์ ์ฌ์ฉlocation.href``location.assign ์ด ๋์ ์ฌ์ฉ๋ฒ๋ง ๋ค๋ฅผ ๋ฟ ๊ธฐ๋ฅ์ ๋์ผํ๋ค window.location.href = "url"; // locati..