JS 获取数组对象的值&提取Object的value

示例

    let val = [{code: '230000', name: '黑龙江省'}, {code: '230100', name: '哈尔滨市'}]
    if (val.length > 0) {
      this.city = val.map(i => i.name) // ["黑龙江省", "哈尔滨市"]
      this.city = val.map(i => i.name).join('-')  // 获取数组对象的值为 黑龙江省-哈尔滨市
    }

posted @ 2024-05-17 14:10  Hekiss  阅读(131)  评论(0编辑  收藏  举报