这是我的代码,我试图将一个全名分成 firstName 和 lastName 两部分。但它不符合我的需要。
Like if fullName='Sachin Ramesh Tendulkar' . then
firstName = Sachin Ramesn
lastName = Tendulkar if
fullName='Sachin Tendulkar' . then
firstName = Sachin
lastname = Tendulkar
if fullName='Sachin Ramesh Tendulkar Second' . then
firstName =Sachin Ramesh Tendulkar
lastName= Second
this.state={
fullName:'Sachin Ramesh Tendulkar'
let fullName = this.state.fullName.split(' ');
const firstName = fullName.shift()
const lastName = fullName.join(' ')
--------------------------------------------
firstName = Sachin
lastName = Ramesh Tendulkar .
but I have to show the result like below ..
------------------------------
firstName = Sachin Ramesh
lastName = Tendulkar
请建议。谢谢
一只甜甜圈
肥皂起泡泡
慕娘9325324
函数式编程
一只斗牛犬
守着一只汪
相关分类