I'm passing a variable customPhoto into the component and want to use it inside the const bg to use in the style. The example below doesn't work - what should I change?
let bg = {
backgroundImage: {`url(${customPhoto})`}
};
The only change I could see in your code is that remove curly brackets before url and at the end
Change
backgroundImage: {`url(${customPhoto})`}
To
backgroundImage: `url(${customPhoto})`
您也可以执行inline-css <div style={{ backgroundImage: `url(${customPhoto})` }}>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.