×
新网 > 建站推广 > 正文

react中如何引进图片

  • 作者:zccc
  • 来源:网络
  • 2020-11-17 18:04:51

react中引进图片的方法:1、方式一【import tsIcon from '../images/typescript.jpeg';】;2、方式二【const tsIcon = require( './images/typescrip】。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> )}

  • 相关专题

免责声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,请发送邮件至:operations@xinnet.com进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。

免费咨询获取折扣

Loading