【问题标题】:if my image src is null then i dont want show image what i want to do?如果我的图像 src 为 null 那么我不想显示图像我想做什么?
【发布时间】:2022-11-17 18:19:21
【问题描述】:

` ${logoPath.map((C) => `<img alt="" class="production-logo" src="${logo.concat(C)}">`)} `

如果我的图像 src 为 null 那么我不想显示图像我想做什么?

javascript中的这段代码

如果我的图像 src 为 null 那么我不想显示图像我想做什么? javacsript 中的这段代码我从 api 获取图像 sourec 一些图像路径为空所以我不想在我的项目中显示该图片给我反馈解决这个错误

【问题讨论】:

    标签: javascript javascript-objects


    【解决方案1】:

    一种可能的解决方案是filter你在map之前logoPath

    ${logoPath.filter(x=>!!x).map(....)}
    

    【讨论】:

      猜你喜欢
      • 2015-10-14
      • 1970-01-01
      • 2015-05-04
      • 2021-10-06
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多