【发布时间】:2017-11-19 10:16:24
【问题描述】:
我正在使用ejs 模板引擎在我的页面上填充数据。
我的 json 文件包含以下字段:
var PhotosSchema = new Schema({
photo_url: {type: String},
thumb_url: {type: String},
hashtags: {type: [String]}
});
到目前为止,我有以下 html 代码:
<div class="thumbnail">
<img src=<%= photo.thumb_url %> >
<div class="caption">
<p><% for(var i=0; i<photo.hashtags.length; i++) {%>
<a href="http://example.com/<%=photo.hashtags[i]%>"><%=photo.hashtags[i] %></a>
<% } %>
| <a href="<%= photo.photo_url %>">full resolution</a></p>
</div>
</div>
它会在照片下方显示主题标签,但它们没有用逗号分隔。例如它看起来像这样:
one two three
我怎样才能修改我的代码,以便它用, 符号划分主题标签,但不将此字符添加到末尾,例如:
one, two, three
这个不正确:
one, two, three,
【问题讨论】:
-
添加一个 if 看看是不是 alst if is than 不要输出它
标签: javascript css ejs