zoukankan      html  css  js  c++  java
  • 下划线连接字符串变驼峰连接

    var arr = [
      'so_no_item',
      'soid',
      'original_part_no',
      'quantity',
      'uom',
      'status',
      'delivery_block',
      'part_description',
      'internal_status',
      'default_warehouse',
      'default_location',
    ]
    arr = arr.map(value => {
      let str = value.split('_')
      let newValue = str[0]
      str.forEach((item,index) => {
        str[index] = str[index].substring(0,1).toUpperCase() +  str[index].substring(1)
        if (index>0) {
          newValue += str[index].substring(0,1).toUpperCase() + str[index].substring(1)
        }
      })
      return {
        name: str.join(' '), 
         160, 
        isShow: true,
        value: newValue
      }
    })
    console.log(JSON.stringify(arr))


    [{"name":"So No Item","width":160,"isShow":true,"value":"soNoItem"},{"name":"Soid","width":160,"isShow":true,"value":"soid"},{"name":"Original Part No","width":160,"isShow":true,"value":"originalPartNo"},{"name":"Quantity","width":160,"isShow":true,"value":"quantity"},{"name":"Uom","width":160,"isShow":true,"value":"uom"},{"name":"Status","width":160,"isShow":true,"value":"status"},{"name":"Delivery Block","width":160,"isShow":true,"value":"deliveryBlock"},{"name":"Part Description","width":160,"isShow":true,"value":"partDescription"},{"name":"Internal Status","width":160,"isShow":true,"value":"internalStatus"},{"name":"Default Warehouse","width":160,"isShow":true,"value":"defaultWarehouse"},{"name":"Default Location","width":160,"isShow":true,"value":"defaultLocation"}]
  • 相关阅读:
    python的整除,除法和取模对比
    jq禁用双击事件
    jq判断滑动方向
    jq获取下拉框中的value值
    html字符串转换成纯文字
    内层div相对于外层div水平垂直居中以及外层div相对body水平垂直居中
    python获取用户输入
    js判断浏览器是否支持localStorage
    CLR的执行模型
    行人检测2(行人检测的发展历史)
  • 原文地址:https://www.cnblogs.com/guozongzhang/p/10942810.html
Copyright © 2011-2022 走看看