Skip to content

kebabCase() function

str 转换为短横线命名。根据空格、标点、数字、大小写边界和缩写词拆分单词。

Signature:

typescript
function kebabCase(str: string): string;

Example

ts
kebabCase("foo bar"); // "foo-bar"
kebabCase("fooBar"); // "foo-bar"
kebabCase("foo_bar"); // "foo-bar"
kebabCase("XMLHttpRequest"); // "xml-http-request"

Open Source Code

Released under the Apache-2.0 License.