当前位置 博文首页 > wusq的博客:vue中数组加Key

    wusq的博客:vue中数组加Key

    作者:[db:作者] 时间:2021-07-16 13:11

    代码:?

    const numberList = list.map(item => ({value: item}))

    ?其中 list是原数组,numberList是转化后的数组,value是key的名称

    ?

    在使用element的el-autocomplete远程搜索组件时,普通的数组不能匹配,需要带有可以的数组才可以。

    这是普通数组

    转化成key为value的数组:

    ?

    cs