简体   繁体   中英

cannot link image in HTML/CSS/REACT stored locally on computer

I was doing an end to end project -> Movie Recommendation, backend server - Python FLASK, frontend - React.Js, so far it is working good but I cannot link my image which is stored inside a folder. Here are some screenshots. (I'm inside Movies.js)
Directory:

在此处输入图片说明

The Code:

在此处输入图片说明

And finally, the output of console.log(image) in inspector console to ensure that the image name is correct:

在此处输入图片说明

I have tried adding require("./movie_posters/movie_name....") but no luck. I need help!

如果您将所有“movie_posters”文件夹移动到公共文件夹,您可以通过在图像 src 属性中使用“/movie_posters/${YOUR_IMAGE_NAME}”来访问它。

缺少require,在渲染之前导入图像。

const image = require("./movie_poster/"+ ... )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM