Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- TypeScript
- MySQL
- 자바 조건문
- 자바 구구단 출력
- java
- 자바 강제 캐스팅
- 자바 공배수
- 타입스크립트
- 자바 삼항연산자
- react ag grid
- 자바 반복문
- 자바 while문
- 자바 if문
- 조코딩
- Til
- 자바 자동캐스팅
- 자바 향상된 for문
- 항해99
- 변수
- 정보처리기사실기
- 자바 public
- 이클립스 DB연동
- 프로그래머스
- 자바
- react with typescript
- 자바 for문
- 자바 스캐너
- Vue3
- 항해99 2기
- 자바 switch문
Archives
- Today
- Total
뇌 채우기 공간
[에러노트] Type 'undefined' is not assignable to type 'Element'. 본문
vue에서 lottie-web을 써서 아래 코드를 작성함
const lottieRef = ref<Element | null>(null);
onMounted(() => {
lottie.loadAnimation({
container: lottieRef.value,
renderer: 'svg',
loop: true,
autoplay: true,
animationData: animationLoading,
});
});
여기서 container 부분에서 빨간줄이 떴다.
Type 'undefined' is not assignable to type 'Element'.
이런 에러가 떴다.
undefined를 잡으면 null 문제라고 또 떴다.
이것을 해결하는 방법은
const lottieRef = ref<Element | null>(null);
onMounted(() => {
if(!lottieRef.value) return;
lottie.loadAnimation({
container: lottieRef.value,
renderer: 'svg',
loop: true,
autoplay: true,
animationData: animationLoading,
});
});
이렇게 체크를 해주면 된다. !
728x90
'에러노트' 카테고리의 다른 글
[에러노트] pnpm install에서 node 버전 오류/ volta , nvm (0) | 2024.01.12 |
---|---|
[에러노트] VScode 에러 날때 (0) | 2023.08.31 |
[에러노트] Failed to load config "react-app" to extend from. (0) | 2022.11.30 |
[에러노트] react form에서 onKeyPress 2번 실행되는 문제 (0) | 2022.05.02 |
[에러노트] A component is changing an uncontrolled input to be controlled. ... (0) | 2022.04.01 |