• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'msg')

22.01.17 14:45 작성 조회수 744

0

computed: {
        syncMsg() {
            return this.$refs.childComponent.msg;
        }
  },

위 코드 부분에 에러가 납니다.

child component 및 msg 데이타도 선언되어 있구요.

어떤 문제일까요?

 

답변 1

답변을 작성해보세요.

0

<template> 에 삽인한 child component의 ref가 childComponent가 맞나요?

예를들어

<template>

 <child-component ref="childComponent" />

</template>

 

this.$refs에서 접근하기 위해서 ref값이 정확히 맞아야 합니다.