react中如何引进图片

coldplay.xixi
coldplay.xixi 原创
2020-11-17 15:49:49 1626浏览

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> )}

相关免费学习推荐:JavaScript(视频)

以上就是react中如何引进图片的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。