fix: 路由地址转首字母大写驼峰,作为路由名称,适配keepAlive

This commit is contained in:
caiti
2022-05-18 11:44:54 +08:00
parent 9ee2fe5eb3
commit 960b1eb250
2 changed files with 15 additions and 0 deletions

View File

@ -427,3 +427,15 @@ export function isNumberStr(str) {
return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str)
}
// -转驼峰
export function toCamelCase(str, upperCaseFirst) {
str = (str || '').toLowerCase().replace(/-(.)/g, function (match, group1) {
return group1.toUpperCase();
});
if (upperCaseFirst && str) {
str = str.charAt(0).toUpperCase() + str.slice(1);
}
return str;
}