问题
In my meteor web app I am trying to change the background of a certain element conditionally with this code:
.popular-games{
background-image: url({{background}});
}
{{background}} being the path it should follow to find the image. This will not work though because the url path needs quotes, and when I put in quotes in negates {{background}}. I've tried putting the quotes into the source where {{background}} is coming from with this code:
background: "\"images/gameArt/fallout4.jpg\""
trying to add in the quotes, but this still does not work for some reason. Any help would be great.
回答1:
You need to have the style in your html like this:
<div style="background-image: url('{{imagePath}}');"></div>
If the file path you return is correct, it will work.
来源:https://stackoverflow.com/questions/37099293/how-do-i-insert-a-meteor-template-that-contains-double-quotes-in-a-place-where-t