也就是[{},{}]这种格式转为{key:value}格式的
如下:把1转换为2这种格式的,解决办法
let platFromTypeFilter = platFromTypeList.reduce((versionObj, item) => ({...versionObj,[item.uid]: item.text}), {})
![](https://img.haomeiwen.com/i14111047/6c5192ccb01a36ec.png)
![](https://img.haomeiwen.com/i14111047/961ac698a24a06bf.png)
对象转为数组格式:
![](https://img.haomeiwen.com/i14111047/48f659ce8ee5b4f5.png)
也就是[{},{}]这种格式转为{key:value}格式的
如下:把1转换为2这种格式的,解决办法
let platFromTypeFilter = platFromTypeList.reduce((versionObj, item) => ({...versionObj,[item.uid]: item.text}), {})
本文标题:数组对象和对象格式互相转换
本文链接:https://www.haomeiwen.com/subject/uqnccjtx.html
网友评论