【发布时间】:2019-12-23 06:23:59
【问题描述】:
如何修复从 Json 到我的 React 组件渲染的本地路径,
我在整个互联网上搜索了答案,但没有运气:(
NOT WORKING :(
[
{
"name": "Apple",
"id": "001",
"price": "$995",
"imgUrl": "./Pictures/219.jpg"
}
]
WORKING, BUT TURTLE SPEED :/
[
{
"name": "Apple",
"id": "001",
"price": "$995",
"imgUrl": "http://www.placekitten.com/200/200"
}
]
从“反应”导入反应 类产品扩展 React.Component { 构造函数(道具){ 超级(道具) }
render() {
return (
<div>
<img src={this.props.imgUrl}> />
<p>Name: {this.props.name}</p>
<p>Id: {this.props.id}</p>
<p>Price: {this.props.price}</p>
</div >
)
}
}
【问题讨论】: