“IMG -Tag in React” Code-Antworten

Bild reagieren

<img src={require('./logo.jpeg')} />

import logo from './logo.jpeg'; // with import    
const logo = require('./logo.jpeg); // with require
<img src={logo} />
Grumpy Goshawk

wie man img jsx schreibt

<img src={window.location.origin + '/img/myImage.png'} />
White Bellied Sea Eagle

reagieren img

import React from 'react';
import logo from './logo.png'; // Tell webpack this JS file uses this image

console.log(logo); // /logo.84287d09.png

function Header() {
  // Import result is the URL of your image
  return <img src={logo} alt="Logo" />;
}

export default Header;
Bewildered Bug

IMG SRC in React JS

import Logo from “./logo.png”;
<img src={Logo}/>
Homely Hornet

So verwenden Sie gespeichertes Bild auf React

<img alt="timer" src={require('./images/timer.png')} />
Runtime Terror

IMG -Tag in React

//two way to use image in react
Option 1: Put the image in the public directory
public/images/thing.jpg, you could display that image this way:
   <img src="images/logo.jpg" />

Option 2: import the image into the component
import Logo from “./logo.jpg”;
<img src={Logo}/>
Sab Tech

Ähnliche Antworten wie “IMG -Tag in React”

Fragen ähnlich wie “IMG -Tag in React”

Weitere verwandte Antworten zu “IMG -Tag in React” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen