“Tag IMG di React” Kode Jawaban

gambar bereaksi

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

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

bagaimana menulis img jsx

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

bereaksi 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 di React JS

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

cara menggunakan gambar yang disimpan di reaksi

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

Tag IMG di 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

Jawaban yang mirip dengan “Tag IMG di React”

Pertanyaan yang mirip dengan “Tag IMG di React”

Lebih banyak jawaban terkait untuk “Tag IMG di React” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya