将带有下划线或者破折号的字符串转换成驼峰形式的字符串(以下划线或者破折号为单词分界)。
除了首字符是下划线、破折号或者是大写字母的时候,转换后的字符首字母需为大写;其他情况,转换后的字符首字母为小写。
- Source:
Example
str.camelize('the_camelize_string_method') // 'theCamelizeStringMethod'
str.camelize('the_camelize_string_method', true) // 'theCamelizeStringMethod'
str.camelize(' the camelize string method') // 'theCamelizeStringMethod'
str.camelize(' the camelize string method', true) // 'theCamelizeStringMethod'
str.camelize('-the-camelize-string-method') // 'TheCamelizeStringMethod'
str.camelize('-the-camelize-string-method', true) // 'theCamelizeStringMethod'
str.camelize('The-camelize-string-method') // 'TheCamelizeStringMethod'
str.camelize('The-camelize-string-method', true) // 'theCamelizeStringMethod'
str.camelize('_som eWeird---name-') // 'SomEWeirdName'
str.camelize('_som eWeird---name-', true) // 'somEWeirdName'
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
str |
String | 需转换成驼峰形式的字符串 | ||
decap |
Boolean |
<optional> |
false
|
true,表示将首字母转换成小写;false,表示不作处理 |
Returns:
转换成驼峰形式的字符串
- Type
- String