UNPKG

@visactor/vue-vtable

Version:
18 lines (16 loc) 537 B
// 将连字符形式的字符串转换为驼峰形式 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 };