/**
* 首字母大写,下划线转驼峰
* @example abc -> Abc
* @example abc_def => AbcDef
*/
formatName (name: string) {
const [first, ...end] = name.split('')
return `${first.toUpperCase()}${end.map(d => d.toLowerCase()).join('')}`.replace(/_\D/g, (match) => {
return match.charAt(1).toUpperCase()
})
}
【JS工具类】首字母大写,下划线转驼峰
最新推荐文章于 2023-11-29 10:17:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)