I want to change the backgroundImage dynamiclly, when i try it follow as, it did not work,but when i open the devtools in chrome, can show that background
<RecommendWrapper>
<RecommendItem imgUrl="../../static/banner.png" >
</RecommendItem>
</RecommendWrapper>
export const RecommendItem = styled.div`
width: 280px;
height: 50px;
background-size: contain;
background: url(${(props)=>props.imgUrl});
`;
if i use like this,it can work,but can't change image dynamic.
import banner from "../../statics/banner.png"
export const RecommendItem = styled.div`
width: 280px;
height: 50px;
background-size: contain;
background:url(${banner});
`;
and if i use a network image(url likes "https://syean.cn/img/avatar.jpg") ,it also can work
{ this.props.recommendList.map((item)=>( <RecommendItem key={item.get("id")} imgUrl={item.get("imgUrl")} > ddd </RecommendItem> )) }
– Hafiz