简体   繁体   English

如何在需要双引号的地方插入包含双引号的流星模板?

[英]How do I insert a meteor template that contains double quotes in a place where those double quotes are needed?

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. {{background}}是查找图片应遵循的路径。 This will not work though because the url path needs quotes, and when I put in quotes in negates {{background}}. 但是,这将无法正常工作,因为url路径需要使用引号,并且当我在否定词{{background}}中加上引号时。 I've tried putting the quotes into the source where {{background}} is coming from with this code: 我尝试使用以下代码将引号放入来自{{background}}的源代码中:

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. 任何帮助都会很棒。

You need to have the style in your html like this: 您需要在html中具有如下样式:

<div style="background-image: url('{{imagePath}}');"></div>

If the file path you return is correct, it will work. 如果您返回的文件路径正确,那么它将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM