emit 2

Vue) 오류 Extraneous non-emits event listeners (함수명) were passed to component but...

Vue3 에서 부모-자식 컴포넌트로 emit을 쓰고 있는데 콘솔창에 아래와 같은 warning 이 떴다. [Vue warn]: Extraneous non-emits event listeners (함수명) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option. 함수는 작동이 잘 되지만 워닝은 최대한 안뜨는게 좋기에 원인을 찾아봤다. 1) 부모 컴포넌트에..

Front-end/Vue.js 2024.02.27

Vue) 자식 -> 부모 컴포넌트에 데이터 넘기기. 부모 컴포넌트에 파라미터 넘기기 emit 사용 방법

자식 컴포넌트에서 부모 컴포넌트에게 데이터를 넘기고자 한다. 부모 컴포넌트의 함수를실행시키는 방법과, 파라미터 여러 개는 어떻게 넘기는지 알아보자. 구조 /* 부모 컴포넌트 */ export default { ...(생략)... ,methods: { testFunc(파라미터1, 파라미터2) { console.log("자식에서 실행명령받음!") } } } // 자식 컴포넌트 export default { ...(생략)... ,methods: { changeNum() { this.$emit('setDate', 파라미터1, 파라미터2); } } } 파라미터 넘기기 부모 컴포넌트에서 자식컴포넌트 태그에 @함수명A = "함수명B" 를 입력한다. ex) 여기서 '함수명A' 는 자식의 호출을 알아차리기 위한 이름이고..

Front-end/Vue.js 2024.02.27
반응형