In react, images use the "<img>" tag, but the path to the image cannot be written directly in the srcs attribute of the tag. You can use "" to introduce images.
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 <img> tag, which defines the image in the web.
But es6 does not support writing the path of the image directly in the <img>
tag, that is, it cannot be used like this <img src="img.png"/>
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('图片url')} />
2) Import method:
import imgURL from '图片url'; <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!