JavaScript로 DOM 접근하는 방법 ⇒ document.querySelector
[before]
const idInput = document.querySellector("#id");
idInput.value = "hansol";
[after]
innerHTML
const inputForm = document.querySelctory("#inputForm");
inputForm.innerHTML += `<input placeholder="ID를 입력해주세요." />;
template literal
const name = "hansol";
const hello = `안녕하세요 저는 ${name} 입니다`;
addEventListener
const test = document.querySelector(".test");
const handleTestClick = () => console.log("Fighting!");
test.addEventListener("click",handleTestClick); // test 노드에 click 이벤트가 등록
API 호출 방법 ( fetch or axios )
async function getData(){
const { data } = await axios.get(`http://localhost:4000/api/datas`);
return data;
}
async await
history 참고
let state = {page_id : 1, data : 'test'};
let url = location.origin + '/myPage';
history.pushState(state, null, url);