이미지 div 부분의 style 템플릿 리터럴 부분이 적용이 되지 않습니다.
미해결
웹 게임을 만들며 배우는 React
render() { const {result, score, imgCoord} = this.state; return ( <> {imgCoord} <div id="computer" style={{ background : `url('https://en.pimg.jp/023/182/267/1/23182267.jpg') ${imgCoord} 0` }}/> <div> <button id="rock" className="btn" onClick={() => this.onClick('바위')}>바위</button> <button id="scissor" className="btn" onClick={() => this.onClick('가위')}>가위</button> <button id="paper" className="btn" onClick={() => this.onClick('보')}>보</button> </div> <div>결과 {result}</div> <div>현재 {score}</div> </> ); } 1. 선생님 방식대로 따라했으나 이미지가 변경되지 않습니다. {imgCoord}를 별도로 꺼내서 찍어보면 변경이 되는데 <div id ="computer" 의 `${imgCoord}`여기에 넣을 경 해당 태그의 속성에서는 값이 변경이 되지 않습니다 .왜그럴까요 ?
- 템플릿리터럴
- react
Na Seunghoo
댓글 2
좋아요 0
조회수 331





