[VueJS][nodeJS] 다른 컴포넌트 메소드 실행하기 (부모, 자식 X)


[VueJS][nodeJS] 다른 컴포넌트 메소드 실행하기 (부모, 자식 X)

REF 선언하기 # 지정한 "이름"이 "refs"에 들어가게 됩니다. 즉, 설정한 "이름"으로 컴포넌트 경로가 지정됩니다. created() { this.$root.$refs.이름 = this; }, methods: { Test() { console.log("호출!"); } } 다른 컴포넌트에서 호출 # 위에서 설정한 컴포넌트 "이름"을 넣어 메소드를 실행합니다. this.$root.$refs.이름.Test(); 예제 # "A 컴포넌트" created() { this.$root.$refs.A = this; }, methods: { action() { this.$root.$refs.B.test(); }, test() { console.log("A 호출!"); } } # "B 컴포넌트" created() { this.$root.$refs.B = this; }, methods: { action() { this.$root.$refs.A.test(); }, test() { console.lo...


#vue #컴포넌트호출 #컴포넌트메소드 #뷰js #뷰 #메소드실행 #다른컴포넌트호출 #다른컴포넌트메소드 #vuejs #호출

원문링크 : [VueJS][nodeJS] 다른 컴포넌트 메소드 실행하기 (부모, 자식 X)