希望在输入框中,输入字符串后,保存时,自动大写首字母。
js string capitalize first letter
【总结】
最后用:
String.prototype.capitalize = function() {
  return this.charAt(0).toUpperCase() + this.slice(1);
}调用:
      if (filteredNewItem.contentOrName) {
        filteredNewItem.contentOrName = filteredNewItem.contentOrName.capitalize()
        console.log("filteredNewItem.contentOrName=", filteredNewItem.contentOrName)
      }输出:
"hello" -> "Hello"
转载请注明:在路上 » 【已解决】js中大写字符串的首字母