using require to import a picture can only write the address of the picture? If the url of my picture is written in the json file, can I only get the picture in the following ways?
< hr >{this.props.data.map((item, index) => {
const url = item.img;
var image = require("../../"+url+".jpg");
return <div key={item.key}>
<a href="-sharp" target="_blank">
<img src={image} className="img_logo"/>
</a>
</div>
})}
in this case, json data cannot write its suffix
. < hr >{
"image":[{
"key":"1",
"img":"static/images/Logo"
}]
}
if I change it to "img": "static/images/Logo.jpg", and the require (".. /" + url) picture won"t show up.
< hr >there is a problem. The url of the image in the json data file given to you by the user must have a suffix name, but the suffix name cannot be rendered if it is written in json. How should the code be modified?