【发布时间】:2022-06-20 16:16:29
【问题描述】:
我正在遍历一组对象,这些对象包含指向图像的链接。其中一些图像返回状态 403 并且不显示。
这是我在 ejs 中的内容
<% Recipes.forEach(recipe => { %>
<div class="basis-2/12 min-w-max">
<% if (recipe.image) { %>
<img class="w-60 h-40 object-cover bg-slate-100 rounded-xl" src="<%= recipe.image %>" />
<% } else { %>
<img class="w-60 h-40 object-cover bg-slate-100 rounded-xl" src="/images/placeholder.png" /> <% } %>
</div>
<% }) %>
if (recipe.name) 本身只检查是否有链接,总是正确的。
我应该怎么做?
【问题讨论】: