】."/> 】.">

Home  >  Article  >  Web Front-end  >  How to quote images in react

How to quote images in react

coldplay.xixi
coldplay.xixiOriginal
2020-12-11 11:58:153576browse

How to reference images in react: 1. Import the image path, the code is [import Img from "./images/1.png"]; 2. Get the image directly, the code is [335a2b195456133ce2de3ca8fd1532aa】.

How to quote images in react

#The operating environment of this tutorial: windows7 system, React17 version, thinkpad t480 computer.

How to reference images in react:

The first way to import the image path

import Img from "./images/1.png"
<img src={Img} alt=""/>

The second way Get the picture directly

<img src={require("./images/1.png")} alt=""/>

If it is a background image, operate style

style={{background:`url(${require("./images/1.png")})` }}

Related learning recommendations: js video tutorial

The above is the detailed content of How to quote images in react. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn