0%

react-web

1.使用svg

1.1 image

1
2
import backIcon from '../assets/svg/back.svg'    
<img src={backIcon} />

1.2 div background

1
2
3
4
5
6
7
import backIcon from '../assets/svg/back.svg'    
<div style={{
background: 'url(' + backIcon + ') no-repeat 50% 50%',
width: width,
height: height,
...style
}} />

1.3 div background-image

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import backIcon from '../assets/svg/back.svg'    
<div style={{
backgroundImage: 'url(' + source + ')',
width: width,
height: height,
...style
}} />
//这个是渐变色背景
<div style={{
backgroundImage: 'linear-gradient(to bottom, #26a9ff 0%, #324dff 100%)',
width: width,
height: height,
...style
}} />