1、camelize:横线转驼峰命名
let camelizeRE = /-(\w)/g;
function camelize(str) {
    return str.replace(camelizeRE, function(_, c) {
        return c ? c.toUpperCase() : '';
    })
}
//ab-cd-ef ==> abCdEf
2、hyphenate:驼峰命名转横线命名:拆分字符串,使用 - 相连,并且转换为小写
let hyphenateRE = /\B([A-Z])/g;
function hyphenate(str){
    return str.replace(hyphenateRE, '-$1').toLowerCase()
}
//abCd ==> ab-cd

 

相关文章:

  • 2021-04-10
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 1970-01-01
猜你喜欢
  • 2021-07-18
  • 2021-11-21
  • 2022-12-23
  • 2021-11-20
  • 2021-06-14
  • 2022-12-23
相关资源
相似解决方案