【发布时间】:2020-12-26 02:29:53
【问题描述】:
我正在尝试根据 JSON 数据中的 JSON 键值添加多个图像
{"名称":"缩写"}-> {“阿拉巴马州”:“AL”, “阿拉斯加”:“AK”, “亚利桑那”:“AZ”, “阿肯色州”:“AR”, “加利福尼亚”:“加利福尼亚”, “科罗拉多”:“CO”,...}
我下载了图像,并根据 JSON 格式的值命名为 'al.png' 、 'ak.png' 、 'az.png' 。如何为我创建的特定卡片组件设置每个图像
import "./card.styles.css"
export const Card =(props)=>(
<div className="card-container">
<h1>{props.states.name}
I am trying to add images here
</h1></div>)"
This is how I am fetching all states name onto Card-list component-
componentDidMount() {
fetch("https://worldpopulationreview.com/static/states/abbr-name-list.json").
then((response) => response.json())
.then(users=>this.setState({states:users}));
}
render() {
return (
<div className='App'>
<CardList states={this.state.states}>
</CardList>
</div>```
【问题讨论】:
-
这些图片在哪里?
标签: javascript html json reactjs