Skip to content

Commit 775548f

Browse files
committed
fix: 组件名驼峰转换
1 parent 11e6722 commit 775548f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/mp-compiler/util.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ function resolveTarget (dir, mpInfo = {}) {
4444
}
4545

4646
// 简单的转换驼峰大写为中横线
47+
const hyphenateRE = /([^-])([A-Z])/g
4748
function covertCCVar (str) {
48-
return (str + '').replace(/[A-Z]/g, v => {
49-
return '-' + v.toLowerCase()
50-
})
49+
return str
50+
.replace(hyphenateRE, '$1-$2')
51+
.replace(hyphenateRE, '$1-$2')
52+
.toLowerCase()
5153
}
5254

5355
// 缓存所有的 slots 节点,生成一个文件

0 commit comments

Comments
 (0)