an error was reported in the field of adding an iconImg to the object data in
react?
Project usage (typescript+react)
import * as React from "react";
import { Row,Col } from "antd";
import s from "./catalog.less";
interface DashProps {
userName ?: any;
}
export default class Index extends React.Component<DashProps, any> {
constructor(props:DashProps) {
super(props);
this.state = {
data:[]
}
}
componentDidMount(){
// let {data}=this.props;
let data= [
{
title:"",
content:"1",
point:["",""]
},
{
title:"",
content:"2",
point:["",""]
},
{
title:"",
content:"3",
point:["",""]
}
]
let iconArr=["/src/assets/img/pointIncon.png","/src/assets/img/pointIncon2.png","/src/assets/img/pointIncon3.png"]
data=data.map((item,index)=>{
item.iconImg=iconArr[index]
return item
})
this.setState({data})
}
render() {
let {data}=this.state;
let items=data.map((item,index)=>{
return (
<div key={index} className={s.item}>
<div className={s.df}>
<span className={s.mr15}><img src={item.iconImg} alt="" className={s.mt5}/></span>
<h2 className={s.fx1}>{item.title}</h2>
</div>
<div className={s.content}>{item.content}</div>
<ul className={s.ml40}>
{
item.point.map((pointItem,pointIndex)=>{
return <li key={pointIndex}>{pointItem}</li>
})
}
</ul>
</div>
)
})
return(
<div className={s.container}>
{items}
</div>
)
}
}