0

I want to show the img randomly, so I use an array to store the path, but it has sth wrong.

const imgSrc=["./static/images/thumb1.jpg","./static/images/thumb1.jpg"]
export default class SongCard extends React.Component {
    render() {
    return (
        <Card  sx={{ display: 'flex'}}>
        <CardMedia
            enter code herecomponent="img"
            image={require("\""+imgSrc[0]+"\"")}  //can not show img
            image={require("./static/images/thumb1.jpg")}   //can correctly show img

0 Answers0