React를 배우려고합니다. 구성 요소 내부의 반환 스타일을 사용할 수없는 이유는 무엇입니까?인라인 스타일이 작동하지 않습니다. ReactJS
오류 : 나는이 또한 시도
The
style
prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX. This DOM node was rendered byHome
.
<div className="single_slide" style="background-image: url(../images/WinterCalling_2016.jpg);">
:이 구문
<div className="single_slide" style={{background-image: 'url(../images/WinterCalling_2016.jpg)'}}>
또는
<div className="single_slide" style={{background-image: url(../images/WinterCalling_2016.jpg)}}>
어떤 도움을 크게 감상 할 수있다. 다른 사람들은 스타일을 말하기 위해 스타일을 바꾸었지만 작동하지는 않는 것으로 보입니다.
'url'은 문자열을 허용하므로 작동하지 않을 것이라고 생각합니다. 이 게시물에있는 것과 같이 문자열 템플릿을 대신 사용할 수 있습니다. http://stackoverflow.com/questions/39195687/setting-a-backgroundimage-with-react-inline-styles –