@visactor/vue-vtable
Version:
The vue version of VTable
18 lines (16 loc) • 537 B
JavaScript
// 将连字符形式的字符串转换为驼峰形式
function toCamelCase(str) {
return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
}
// 将 vnode.props 中的所有属性名转换为驼峰形式
function convertPropsToCamelCase(props) {
const newProps = {};
for (const key in props) {
if (props.hasOwnProperty(key)) {
const camelCaseKey = toCamelCase(key);
newProps[camelCaseKey] = props[key];
}
}
return newProps;
}
export { convertPropsToCamelCase, toCamelCase };