react中怎样引进图片
更新:HHH   时间:2023-1-7


这篇文章给大家分享的是有关react中怎样引进图片的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。

react中引进图片的方法:1、方式一【import tsIcon from '../images/typescript.jpeg';】;2、方式二【const tsIcon = require( './images/typescrip】。

react中引进图片的方法:

方式一:

import tsIcon from '../images/typescript.jpeg';

方式二:

const tsIcon = require( '../images/typescript.jpeg');

使用方式一:

<img src={tsIcon} alt= "" />

使用方式二:

<div style={{ background: `url(${tsIcon}) no-repeat`}}> </div>

使用方式三:

const styles = { test: { background: `url(${tsIcon}) no-repeat center` }}render() { return ( <div style={styles.test}></div> )}

感谢各位的阅读!关于react中怎样引进图片就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到吧!

返回web开发教程...