Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 设置';src&x27;使用主干模板动态生成img标签_Javascript_Backbone.js - Fatal编程技术网

Javascript 设置';src&x27;使用主干模板动态生成img标签

Javascript 设置';src&x27;使用主干模板动态生成img标签,javascript,backbone.js,Javascript,Backbone.js,我正在尝试使用主干模板动态设置img标记的src,但是/会自动追加img未加载的标记。模板部分如下所示- <script type="text/template" id="home"> ....... <% var d=names[0].get("image_link")+".jpg" //d=d.substring(0 , d.length-1); tried to cut down last char %> <a href="#" class="thumbna

我正在尝试使用主干模板动态设置
img
标记的
src
,但是
/
会自动追加
img
未加载的标记。模板部分如下所示-

<script type="text/template" id="home">
.......
<% var d=names[0].get("image_link")+".jpg" 
//d=d.substring(0 , d.length-1); tried to cut down last char
%>
<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all"  width="100%" height="auto" src=<%=d%> /> 
.......
</script>

.......
/> 
.......
输出-

<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all"  width="100%" height="auto" src="image1.jpg/" />


我不知道如何在
img
src中排除
/
。请给我任何建议。

代码中实际上有斜杠。由于属性值周围没有任何引号,因此
/
中的
/
将成为该值的一部分

添加引号:

<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all"  width="100%" height="auto" src="<%=d%>" />
“/>

斜杠实际上在代码中。由于属性值周围没有任何引号,因此
/
中的
/
将成为该值的一部分

添加引号:

<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all"  width="100%" height="auto" src="<%=d%>" />
“/>

斜杠实际上在代码中。由于属性值周围没有任何引号,因此
/
中的
/
将成为该值的一部分

添加引号:

<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all"  width="100%" height="auto" src="<%=d%>" />
“/>

斜杠实际上在代码中。由于属性值周围没有任何引号,因此
/
中的
/
将成为该值的一部分

添加引号:

<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all"  width="100%" height="auto" src="<%=d%>" />
“/>