vue源码之驼峰转连字符

var hyphenateRE = /\B([A-Z])/g; var hyphenate = function (str) { return str.replace(hyphenateRE, ‘-$1‘).toLowerCase() } console.log(hyphenate("aaaaDssssFcccc"));? ? //??aaaa-dssss-fcccc

// "-$1":捕获到什么字符$1就引用什么字符,字符加一个“-”

相关推荐