• 数组替换成一个新数组


    if(this.goldUsers[i].label.length>1){
    let a = this.goldUsers[i].label
    a [20001, 20004]
    let c = {
    20001:'大理石',
    20002:'人造石',
    20003:'石英石',
    20004:'花岗石',
    }
    let b = a.map(item=>{
    return c[item]
    })
    console.log(b)
    b ["大理石", "花岗石"]
    // 第一中
    // let b = a.map(item=>{
    // if(item === 20001){
    // return '大理石'
    // }else if(item === 20002){
    // return '人造石'
    // }else if(item === 20003){
    // return '石英石'
    // }else if(item === 20004){
    // return '花岗石'
    // }
    // })
    // console.log(11,b)
    // 第二中
    // for(let j = 0;j < a.length;j++){
    // if(a[j] == 20001){
    // a[j] = '大理石'
    // }else if(a[j] == 20002){
    // a[j] = '人造石'
    // }else if(a[j] == 20003){
    // a[j] = '石英石'
    // }else if(a[j] == 20004){
    // a[j] = '花岗石'
    // }
    // console.log(3,a[j])
    //
    // }
    // console.log(34,this.goldUsers[i].label)
    this.goldUsers[i].label = b
    }
  • 相关阅读:
    17.CSS 文本属性和字体属性
    15.CSS 浮动
    D. Same GCDs
    B. Infinite Prefixes
    D. 0-1 MST
    lambda表达式复习
    D. New Year and Conference
    C. New Year and Permutation
    D. Dr. Evil Underscores
    D. Minimax Problem
  • 原文地址:https://www.cnblogs.com/isuansuan/p/11462630.html
Copyright © 2020-2023  润新知