【发布时间】:2019-11-30 12:14:26
【问题描述】:
我有一个一维列表。我必须将其转换为三维列表。我该如何管理它?
这些是我的清单。
this.galleryImages = [
{
small: 'https://res.cloudinary.com/tasit-com/image/upload/c_thumb,w_640,h_480,e_sharpen:120/ccd97b3bb468f62162e1ce7557f25a06.jpg',
medium: 'https://res.cloudinary.com/tasit-com/image/upload/c_thumb,w_640,h_480,e_sharpen:120/ccd97b3bb468f62162e1ce7557f25a06.jpg',
big: 'https://imganuncios.mitula.net/renault_clio_2017_motorin_1_94_vade_orani_40_pe_i_n_48ay_taksi_t_duzgun_ti_caret_bunyesi_nde_3720113557242259227.jpg',
},
{
small: 'https://imganuncios.mitula.net/renault_clio_2017_motorin_1_94_vade_orani_40_pe_i_n_48ay_taksi_t_duzgun_ti_caret_bunyesi_nde_3720113557242259227.jpg',
medium: 'https://imganuncios.mitula.net/renault_clio_2017_motorin_1_94_vade_orani_40_pe_i_n_48ay_taksi_t_duzgun_ti_caret_bunyesi_nde_3720113557242259227.jpg',
big: 'https://imganuncios.mitula.net/renault_clio_2017_motorin_1_94_vade_orani_40_pe_i_n_48ay_taksi_t_duzgun_ti_caret_bunyesi_nde_3720113557242259227.jpg'
},
{
small: 'https://www.ihaleden.com/uploads/media/5c6f93d30a4a4.png',
medium: 'https://www.ihaleden.com/uploads/media/5c6f93d30a4a4.png',
big: 'https://www.ihaleden.com/uploads/media/5c6f93d30a4a4.png'
}
]
我的一维列表是 selectedFilesList。我想将此列表转换为 3 维列表并与其他列表相等。
【问题讨论】:
-
3 dimensional是什么意思?您能否编辑问题以提供所需的结构? -
就这样?现在你能帮我哈伦爵士吗?
-
我的意思是您希望将数组转换为
this.galleryImages['small'][0]或this.galleryImages['medium'][2]而不是this.galleryImages[0]['small']或this.galleryImages[2]['medium']? -
我有一个一维数组。我想将其转换为 3d 数组,将每个项目重复 3 次
-
请考虑编辑此问题中的代码以构成minimal reproducible example。这应该包括输入和所需的输出。现在你只有问题中的输出,以及评论中的输入草图。看起来您想要
inArr.map(x => ({small: x, medium: x, large: x})),但如果没有实际的示例代码,我们无法确定。祝你好运!
标签: angular typescript