[vue] 이미지를 동적으로 넣을 때

Edward Hyun·2021년 12월 17일
0

app&web-dev

목록 보기
43/178

이미지를 동적으로 이미지 주소를 'text'값으로 넣게 되면 로딩이 되지 않는다.
import 나 require를 사용해야 한다.

import image1 from '이미지 주소';
import image2 from '이미지 주소';
import image3 from '이미지 주소';

함수 = computed (() => {
 return 조건에 맞는 image;
}

img태그에서 :src="함수" 로 설정하면 이미지를 로딩되어 나온다.

참고 :: https://stackoverflow.com/questions/53950105/how-do-i-bind-a-src-for-an-image-in-the-child-component/53952017#53952017

profile
앱&웹개발(flutter, vuejs, typescript, react), 인공지능(nlp, asr, rl), 백엔드(nodejs, flask, golang, grpc, webrtc, aws, msa, nft, spring cloud, nest.js), 함수형 프로그래밍(scala, erlang)을 공부하며 정리합니다.

0개의 댓글