---
title: "upperFirst"
description: "仅将字符串的第一个字母转换为大写。"
seo_title: "upperFirst"
seo_description: "Uppercase only the first character of a string while preserving the rest, a small helper for sentence and label formatting."
canonical_url: "https://core.mhaibaraai.cn/docs/transformers/string/upper-first"
---
# upperFirst

> 仅将字符串的第一个字母转换为大写。

## 用法

仅将字符串的第一个字母转换为大写，其余部分保持不变。

```ts
import { upperFirst } from '@movk/core'

upperFirst('foo bar') // => 'Foo bar'
upperFirst('FOO BAR') // => 'FOO BAR'
```

## API

`upperFirst(str: string): string`

### 参数

**str** (`string`) *required*: 要转换的字符串。

### 返回值

**string**: 返回首字母大写的字符串。

## Changelog

See commit history for [src/transformers/string/upperFirst.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/transformers/string/upperFirst.ts).


## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
