Notice
Recent Posts
Recent Comments
목록HOOK (1)
송민준의 개발노트
![](http://i1.daumcdn.net/thumb/C150x150.fwebp.q85/?fname=https://blog.kakaocdn.net/dn/n5m8m/btrsxEb6S52/pYfeTfOO9re4qUFpRmRNAk/img.png)
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'example') 콘솔에서 위와 같이 부모컴포넌트에서 자식컴포넌트의 'example'이라는 데이터를 참조하여 초기 렌더링 시에 발생하는 문제를 해결하는 방법이다. 문제의 코드는 아래와 같다. computed를 이용해서 refs로 example이라는 데이터에 접근을 했더니 위와 같은 문제가 생긴 것이다. // 부모 컴포넌트 {{ example }} // 자식 컴포넌트 자식 코드를 아래와 같이 고쳐주자. computed: { example () { return this.$refs.child?.example || '대체 문자' } }, 해결방법은 옵셔널 체이닝을 사용해서..
웹/Vue
2022. 2. 7. 00:13