const Row = [
{
name: "jad",
link :"/jad",
calories :"52",
Fat :"4",
Carbs :"5",
Protein :"41"
},
{
name: "john",
link :"/john",
calories :"82",
Fat :"42",
Carbs: "35",
Protein :"1"
}
]
const [myList, setMyList] = React.useState(Row);
function handle(){
setMyList()
}
{
myList.map((item)=> {
return (
{item.name}
{item.calories}
{item.Fat}
{item.Carbs}
{item.Protein}
}>
Delete
)
})
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
通过循环解析
myList,找到特定的键,更新键的新值,然后使用更新后的myListsetMyList。