IT개발/Vue.js
[Vue] component A 에서 component B 함수 호출 방법2
딸바보아재
2021. 7. 29. 11:27
반응형
// Component A
Vue.component('UserMngtSearchForm', {
created() {
//생성될때, root 콤포넌트의 refs에 유니크하게 Component A의 this객체를 바인딩함.
this.$root.$refs.UserMngtSearchForm = this;
},
methods: {
search: function() {
alert('UserMngtSearchForm search is called');
}
}
});
// Component B
Vue.component('UserMgntDetailForm', {
methods: {
deleteItem: function() {
//삭제후, Component A의 search 함수 호출
this.$root.$refs.UserMngtSearchForm.search();
}
}
});
반응형