当前第2页 返回上一页
(1)render()方法内定义为对象
1 2 3 4 5 6 7 8 9 | const bgGround {
display: 'inline-block',
height: '40px',
width: '40px',
background: `url(${require("图片路径")})`
}
// 在return中使用
< span style={bgGround}>xxxxx</ span >
|
(2)import引入
1 2 3 4 5 6 7 8 9 | import imgUrl from '图片路径'
// render()中定义为对象
const bgGround = {
display: 'inline-block',
height: '40px',
width: '40px',
backgroundImage: 'url(' + imgUrl + ')'}
//在return中使用
< span style={bgGround}>xxxxx</ span >
|
相关推荐:react教程
以上就是如何在react页面中引入本地图片的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
React移动端框架有哪些
redux如何关联React?
React native的特点是什么
React native是什么框架?
React中怎么获取数据
vue和React有什么相似点
使用React native的好处是什么?
weex和React native区别是什么
前端React是什么
React jsx是什么
更多相关阅读请进入《React》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » 如何在react页面中引入本地图片