如何在react中使用require()和变量名?

我已经阅读了许多关于堆栈溢出和博客的解决方案,但是没有一个可以解决我的问题。 我有来自api的图片网址。这很罕见,但这是我的任务

{
    id: 12,
    title: "Cat Tee Black T-Shirt",
    description: "4 MSL",
    availableSizes: ["S", "XS"],
    style: "Black with custom print",
    price: 10.9,
    installments: 9,
    currencyId: "USD",
    currencyFormat: "$",
    isFreeShipping: true,
    src_1: "../../assets/113_1.jpg",
    src_2: "../../assets/113_2.jpg"
  },

here I am displaying image as <img src=require(src_1)> but it doesn't work as require() only works with static url. Could someone pls help me?

评论