【发布时间】:2019-11-16 07:45:39
【问题描述】:
谁能帮我提取带有href 的所有链接?
这是map 代码:
const image = images.map(img => img.links)
{ image.map(a => a.map( b => b.href))}
还有其他方法吗?
这是数据
{
'item': [
{
'data': [
{'href': link}
]
},
...
{
'data': [
{'href': link}
]
},
]
}
【问题讨论】:
-
你能再分享一些代码吗,你在做什么,你在解析什么?
-
我有一个 API link,我需要将所有图像放入我的反应组件中
-
你希望你的输出是什么样子的?只需分享 JSON 对象的格式即可。
-
const ImagesGallery = ({images}) => { useEffect( () => { onImagesGallery() }, [onImagesGallery]) const image = images.map(img => img.links) return ( { image.map(a => a.map( b => <div className={style.wrapper__container__content} key={b.index}> <img src={b.href ? b.href : noImage} alt=""/> </div> )) } ) } const mapStateToProps = state => ({ images: state.imagesGalleryPage.items, })
标签: javascript arrays reactjs object