-
Vue.js) 부모 자식 component끼리 데이터 주고 받기Programing Language/Vue.js 2021. 6. 1. 10:35728x90반응형This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Props are for parent -> child You can use $emit for child -> parent v-on directive captures the child components events that is emitted by $emit //////////////////////////////////////////////////////////////////// //Child component triggers clicked event : export default { methods: { onClickButton (event) { this.$emit('clicked', 'someValue') } } } //////////////////////////////////////////////////////////////////// //Parent component receive clicked event: <div> <child @clicked="onClickChild"></child> </div> ... export default { methods: { onClickChild (value) { console.log(value) // someValue } } } 728x90반응형'Programing Language > Vue.js' 카테고리의 다른 글
Vue.js) vue 3.0 에서 npm install xx 이후 모듈 파일에서 Vue.prototype문법 install오류 (Cannot set property '$xx' of undefined) (0) 2021.06.01 Vue.js) Vue 3.0 에서 vue-session 사용하기 (0) 2021.06.01 Vue.js) router-link 태그를 javscript 코드로 사용하는 방법 (0) 2021.05.28 Vue.js) 휴대폰 번호 입력 폼 maxLength 적용 시키기 (0) 2021.05.28 Vue.js) express에 vue.js 배포할때 vue.config.js 파일코드 (0) 2021.05.25