Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | export default function EventBasic({ type }) { // click 이벤트 핸들러 const current = () => { const d = new Date(); // type 속성 값에 따라 현재 날짜 및 시각을 로그에 출력한다. switch(type) { case 'date': console.log(d.toLocaleDateString()); break; case 'time': console.log(d.toLocaleTimeString()); break; default: console.log(d.toLocaleString()); break; } }; return ( <div> {/* 버튼 클릭 시 current 함수 호출 */} <button onClick={current}>현재 시각 가져오기</button> </div> ); } |