通过split将字符串分割成数组
-font-size //['', 'font', 'size']
font-size //['font', 'size']
function cssStyle2DomStyle(sName) {
var arr = sName.split('-').filter(item => item!='')
for(let i=1; i<arr.length; i++){
arr[i] = arr[i].charAt(0).toUpperCase()+arr[i].substring(1)
}
return arr.join('')
}
标签:sName,驼峰,item,split,字符串,font,size
From: https://www.cnblogs.com/poco-o/p/16823846.html