const editorOpen = () => {
noticeDialogRef.value.open("에디터 제목",false,"에디터 내용")
}
이런 식으로 자식의 메서드를 호출하고
const open = (_title:"", _isViewer: false, _content:"") => {
consoleLog("거래처 공지 open");
isOpen.value = true;
title = _title;
isViewer = _isViewer;
contents = _content;
};
자식 메서드에서 매개변수를 이렇게 받을 수 있다.
이걸 JSON 객체로 주고 받는 방법으로 변경하게 되면
const editorOpen = () => {
noticeDialogRef.value.open({
title:"에디터 제목",
isViewer:false,
content:"에디터 내용"})
}
const open = (data = { title:"", isViewer: false, content:"" }) => {
consoleLog("거래처 공지 open");
isOpen.value = true;
title = data.title;
isViewer = data.isViewer;
contents = data.content;
};
이렇게 된다.
const open = (data = { title:"", isViewer: false, content:"" }) => {
이건 기본값을 주고 싶을 때 쓰는 방법이고
기본값 안줘도 되면
const open = (data) => {
이렇게 하면 된다.
객체 변수명은 꼭 data 일 필요는 없다.
'웹 개발 > 개념 정리' 카테고리의 다른 글
| [Sort] Bubble Sort, Selection Sort, Insertion Sort (C언어) (0) | 2026.03.09 |
|---|---|
| [디자인패턴] MVC, MVP, MVVM 이란 무엇인가 (0) | 2025.11.12 |
| 파라미터 / JSON 요청(3) 최종 예제 (0) | 2025.08.05 |
| 파라미터 / JSON 요청(2)에 따른 컨트롤러 ~ 와 제네릭 간단 설명 (4) | 2025.08.01 |
| @RequiredArgsConstructor (0) | 2025.06.17 |