我尝试使用ReactJS创建一个菜单网站。我有一些组件,他们都工作正常,但我唯一的问题是,我的图像不显示。我有一系列的数据,我想为他们使用图像。它们并不像我们说的那样,
import React from "react";
const FoodMenus = [
{
name: "Pizza Margherita",
ingredients: "Tomato and mozarella",
price: 10,
photo: "../assets/margherita.jpg",
soldOut: false,
},
...
]
我尝试了所有的方法导入图像一样;
import React from "react";
const FoodMenus = [
{
name: "Pizza Margherita",
ingredients: "Tomato and mozarella",
price: 10,
photo: "/src/assets/focaccia.jpg",
soldOut: false,
},
...
]
这个也不管用。
1条答案
按热度按时间nfeuvbwi1#
你可以试试这个