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"}]
  • 相关阅读:
    EXTJS 的PagingToolbar.js
    extjs之gridpanel完全操作(事件)
    Asp.net的服务器推技术 (Server Push) .NET
    Extjs 右下角弹出框 可弹出多个 冒泡小窗体
    Web IM技术简介
    iphone 开发图片显示圆角效果
    linux 修改IP, DNS 命令
    Mysql Data目录生成大量mysqlbin.****
    linux下查看内存使用情况
    rpm卸载mysql
  • 原文地址:https://www.cnblogs.com/guozongzhang/p/10942810.html
Copyright © 2011-2022 走看看