" tag, but the path to the image cannot be directly written in the srcs attribute of the tag. It can be introduced in the form of "" picture."/> " tag, but the path to the image cannot be directly written in the srcs attribute of the tag. It can be introduced in the form of "" picture.">

Home  >  Article  >  Web Front-end  >  What tags are used for images in react

What tags are used for images in react

青灯夜游
青灯夜游Original
2020-12-18 11:26:412508browse

In react, images use the "a1f02c36ba31691bcfe87b2722de723b" tag, but the path to the image cannot be written directly in the srcs attribute of the tag. You can use "d3891d8c5de441245b6f00b1304f7f5f" to introduce images.

What tags are used for images in react

The operating environment of this tutorial: windows7 system, react16 version. This method is suitable for all brands of computers.

Recommended related tutorials: React video tutorial

The tags used for images in React are the same as those in HTML, which is the a1f02c36ba31691bcfe87b2722de723b tag, which defines the image in the web.

But es6 does not support writing the path of the image directly in the a1f02c36ba31691bcfe87b2722de723b tag, that is, it cannot be used like this 5a8cca8a9993efcacfe4f9d3ff141824

So how to introduce images into react? Solution:

Introducing images into react, methods that can be used:

1) Recommended use: require method. It should be noted that with this method, only strings can be written in require. , cannot write variables.

<img src={require(&#39;图片url&#39;)} />

2) Import method:

import imgURL from &#39;图片url&#39;;
<img src={imgURL } />

For more programming-related knowledge, please visit: Programming Teaching! !

The above is the detailed content of What tags are used for 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