Commit 029c5f92 authored by youjie's avatar youjie

no message

parent e1707fdf
......@@ -1987,5 +1987,29 @@ export default {
var language = localStorage.getItem('language')
return language;
}
Vue.prototype.deepFirstLetterToLower = function (obj) {
if (typeof obj !== 'object' || obj === null) return obj; // 非对象直接返回
// 处理数组:遍历每个元素递归转换
if (Array.isArray(obj)) {
return obj.map(item => deepFirstLetterToLower(item));
}
// 处理普通对象:遍历键值对递归转换
const newObj = {};
for (const key in obj) {
const value = obj[key];
// 键名首字母转小写(可选,根据需求)
const newKey = firstLetterToLower(key);
newObj[newKey] = deepFirstLetterToLower(value);
}
return newObj;
}
// 基础首字母转小写函数(同上)
Vue.prototype.firstLetterToLower = function (str) {
if (typeof str !== 'string' || str.length === 0) return '';
return str.charAt(0).toLowerCase() + str.slice(1);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment