简体   繁体   中英

Split string in React

I am trying to split a string being received from a props. For example: this.props.searchedBook=Cinderella (a fairy tale).

I am displaying that data like:

<span>You currently don't have data for <p>{this.props.searchedBook}</p></span>

I want to display only Cindrella . How do I do that?

如果名称始终在this.props.searchedBook排在this.props.searchedBook ,则可以使用此名称

  this.props.searchedBook.split(' ')[0]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM