stringFun.js 474 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
export const toUpperCase = (str) => {
    if (str[0]) {
        return str.replace(str[0], str[0].toUpperCase())
    } else {
        return ""
    }
}

// 驼峰转换下划线
export const toSQLLine = (str) => {
    if (str=="ID") return "ID"
    return str.replace(/([A-Z])/g,"_$1").toLowerCase();
13 14 15 16 17 18 19 20
  }

  // 下划线转换驼峰
  export const  toHump = (name) => {
    return name.replace(/\_(\w)/g, function(all, letter){
        return letter.toUpperCase();
    });
}