How to capitalize first letter and lowercase the rest of the string

后端 未结 5 1226
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-20 05:22

I am trying to capitalize the first letter of only the first word in a sentence.

This is the data in the tsx file { this.text({ id: downloadPriceHistory

5条回答
  •  一向
    一向 (楼主)
    2021-01-20 06:12

    My suggestion is you get the first element of string and put in uppercase and get the rest of string and apply lowercase function.

    titleCase(string) {
      return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
    }
    

提交回复
热议问题