let str = "zifu_chuan_chang" function func(str) { let arr = str.split('_') let resStr = arr.reduce(function(prev, cur){ let str = prev + cur.slice(0, 1).toUpperCase() + cur.slice(1) return str }) // 转小驼峰这一行不需要 resStr = resStr.slice(0, 1).toUpperCase() + resStr.slice(1) return resStr } console.log(func(str))