UNPKG

@visactor/vue-vtable

Version:
21 lines (18 loc) 597 B
'use strict'; // 将连字符形式的字符串转换为驼峰形式 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; } exports.convertPropsToCamelCase = convertPropsToCamelCase; exports.toCamelCase = toCamelCase;