// 驼峰命名转换成短横线命名
const getKebabCase = (str) => {
return str.replace(/[A-Z]/g, (item) => '-' + item.toLowerCase())
}
// 短横线命名转换成驼峰命名
const getCamelCase = (str) => {
return str.replace(/-([a-z])/g, (i, item) => item.toUpperCase())
}
驼峰命名与短横线之间的转换
最新推荐文章于 2025-03-20 19:29:17 发布
文章介绍了如何使用JavaScript实现驼峰命名(CamelCase)和短横线命名(kebab-case)之间的转换,提供了两个相应的函数getKebabCase和getCamelCase。
1620

被折叠的 条评论
为什么被折叠?



