reactjs - 如何更改对象数组的状态。使用它们的数组位置
问题描述
例如我想改变状态route[2]--> address --> apt_plot
但是我面临的问题是我怎样才能像
setRoute([2])
有人可以帮助那样访问位置 2。下面的示例数据。将此作为解决方案的参考。
const [route, setRoute] = useState([
{
address : {
apt_plot: '',
street: '',
city: '',
state: '',
zip_code: '',
},
geo_location : {
latitude: '',
longitude: '',
}
},
{
address : {
apt_plot: '',
street: '',
city: '',
state: '',
zip_code: '',
},
geo_location : {
latitude: '',
longitude: '',
}
},
{
address : {
apt_plot: '',
street: '',
city: '',
state: '',
zip_code: '',
},
geo_location : {
latitude: '',
longitude: '',
}
}
])
解决方案
推荐阅读
- python - Gimp Python 脚本未显示在菜单中
- lc3 - 您将如何编写代码以在用户输入的 2 个值之间添加每 4 个数字?
- python - Python聊天机器人项目上的Tensorflow错误
- javascript - 动态检查复选框是否被即时选中
- python - 如何在linux ubuntu终端上安装python3.9?
- sql - 检查每个值的数据类型的存储过程
- php - 从 SELECT 获取结果,然后将其更新到数据库 MySQL 和 PHP
- javascript - 如何单击具有更多边界的 svg 行标签?
- python - python数据帧上的平均值和最大值
- python - 如何找到将项目移动到堆栈中某个位置的最小移动次数?