---
title: "kebabCase"
description: "将字符串转换为短横线式 (hello-world)。"
canonical_url: "https://core.mhaibaraai.cn/docs/transformers/string/kebab-case"
---
# kebabCase

> 将字符串转换为短横线式 (hello-world)。

## 用法

将字符串转换为短横线命名格式（kebab-case）。

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

kebabCase('firstName') // => 'first-name'
kebabCase('First Name') // => 'first-name'
kebabCase('first_name') // => 'first-name'
kebabCase('XMLHttpRequest') // => 'xml-http-request'
```

## API

`kebabCase(str: string): string`

### 参数

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

### 返回值

**string**: 返回短横线式格式的字符串。

## Changelog

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

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/transformers/string/kebabCase.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
