“(id: any, title: any, body: any, image: any) => Element”类型的参数不可分配给类型的参数
Argument of type '(id: any, title: any, body: any, image: any) => Element' is not assignable to parameter of type
我是React-Native的新手。我正在尝试将数据映射到视图中。一直试图解决这个问题,通读了文档和其他资源但未能成功。我在这里做错了什么?
数据
const data = [
{
id: "1",
title: "Online Appointment",
body: "Select the specialist and make an appointment through our App!",
image: "../../../assets/images/intro1.png",
},
{
id: "2",
title: "Emergency Call",
body: "Just In One Click Our Quick Response Team Will Provide You First Aid!",
image: "../../../assets/images/intro2.png",
},
{
id: "3",
title: "Online Pharmacy",
body: "You Can Buy and Sell Medical Equipments Through Our App!",
image: "../../../assets/images/intro3.png",
},
]
我正在使用这些数据来映射这里:
{data.map((id, title, body, image) => {
return (
<View style={TOPCOLUMN} key={id}>
<ImageBackground source={{ uri: image }} style={INTROIMAGE}>
<Text style={TITLE}>{title}</Text>
<Text style={CONTENT}>{body}</Text>
</ImageBackground>
</View>
)
})}
我得到的错误
Argument of type '(id: any, title: any, body: any, image: any) => Element' is not assignable to parameter of type '(value: { id: string; title: string; body: string; image: string; }, index: number, array: { id: string; title: string; body: string; image: string; }[]) => Element'.
你忘了销毁
{data.map((id, title, body, image) => {
应该是
{data.map(({id, title, body, image}) => {
我是React-Native的新手。我正在尝试将数据映射到视图中。一直试图解决这个问题,通读了文档和其他资源但未能成功。我在这里做错了什么?
数据
const data = [
{
id: "1",
title: "Online Appointment",
body: "Select the specialist and make an appointment through our App!",
image: "../../../assets/images/intro1.png",
},
{
id: "2",
title: "Emergency Call",
body: "Just In One Click Our Quick Response Team Will Provide You First Aid!",
image: "../../../assets/images/intro2.png",
},
{
id: "3",
title: "Online Pharmacy",
body: "You Can Buy and Sell Medical Equipments Through Our App!",
image: "../../../assets/images/intro3.png",
},
]
我正在使用这些数据来映射这里:
{data.map((id, title, body, image) => {
return (
<View style={TOPCOLUMN} key={id}>
<ImageBackground source={{ uri: image }} style={INTROIMAGE}>
<Text style={TITLE}>{title}</Text>
<Text style={CONTENT}>{body}</Text>
</ImageBackground>
</View>
)
})}
我得到的错误
Argument of type '(id: any, title: any, body: any, image: any) => Element' is not assignable to parameter of type '(value: { id: string; title: string; body: string; image: string; }, index: number, array: { id: string; title: string; body: string; image: string; }[]) => Element'.
你忘了销毁
{data.map((id, title, body, image) => {
应该是
{data.map(({id, title, body, image}) => {