Home > Blockchain >  React: Image is not displayed
React: Image is not displayed

Time:05-25

Im folgenden Code sieht man wie ich das bild darstellen möchte, das Bild wird aber nicht angzeigt, nur der text wird angezeigt.

<div> <b> Test123 </b> <image src={require('../../assets/images/homepage/homepage-splash-1.jpeg')} alt='loading...'></image> </div>

CodePudding user response:

as far as I know, one way to use local image address is to import it. something like this:

import homePageSplash from "../../assets/images/homepage/homepage-splash-1.jpeg"

return (<img src={homePageSplash} alt="" />)

CodePudding user response:

You don't need to use require here. Only specify the path to the image

<image src='../../assets/images/homepage/homepage-splash-1.jpeg' alt='loading...'></image>

CodePudding user response:

You need to import your image first outside the class of react view file. Like on the top like this:

import imageName from 'images/yourImageName.png';

Now inside the class of react file you can call this image like this:

<img src={imageName}  alt="Image Title"/>
  • Related