refactor: refacotr preference
This commit is contained in:
20
packages/@vben-core/shared/toolkit/src/letter.ts
Normal file
20
packages/@vben-core/shared/toolkit/src/letter.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 将字符串的首字母大写
|
||||
* @param string
|
||||
*/
|
||||
function capitalizeFirstLetter(string: string): string {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串的首字母转换为小写。
|
||||
*
|
||||
* @param str 要转换的字符串
|
||||
* @returns 首字母小写的字符串
|
||||
*/
|
||||
function toLowerCaseFirstLetter(str: string): string {
|
||||
if (!str) return str; // 如果字符串为空,直接返回
|
||||
return str.charAt(0).toLowerCase() + str.slice(1);
|
||||
}
|
||||
|
||||
export { capitalizeFirstLetter, toLowerCaseFirstLetter };
|
Reference in New Issue
Block a user