node.js - 有没有办法在 React 中访问根目录之外的图像
问题描述
想法是使用 Express 将图像上传到 React 根文件夹之外的文件夹中,然后使用数据库中的图像名称,从文件夹中获取图像文件。
app.use(express.static(path.join(__dirname, "client/build")));
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "client", "build", "index.html"))
})
解决方案
推荐阅读
- python-3.x - 用实际值替换指标值
- vb.net - 如何在文本框中将 60 格式化为 01m:00s?在 vb.net
- php - laravel 访问子查询内的外部查询列
- java - 如何从Java中结构类似于XML的文件中获取特定元素
- google-apps-script - 可以使用 QUERY 在同一个工作簿中组合多个工作表吗?
- javafx - 如何从 javafx new Scene 自动运行代码
- wpf - 当列表视图中出现重复行时,listview.ScrollIntoView(listview.SelectedItem) 不起作用
- html - 网格项目的响应式视图,使它们彼此重叠
- c++ - 我在 C++ 中实现了我自己的平方根函数以获得高达 9 点的精度,但它不起作用
- xamarin.forms - 我可以指定collectionView中每个元素的宽度和高度吗?