React JSX concat multiple {this.state} {this.props}

问题描述 投票:0回答:1
{this.state.userFirst} //returns anime
{this.props.firstPlace} //returns netflix
{this.props.provider[0].netflixAnimeT //returns 495

我当前的代码是...

<p>
  {this.Capitalize(this.props.firstPlace)} has
  {`this.props.provider[0].${this.props.firstPlace}${this.Capitalize(
    this.state.userFirst || ""
  )}T`}
  {this.state.userFirst}
</p>;
Capitalize (str){
  return str.charAt(0).toUpperCase() + str.slice(1)
}

当前输出:

Netflix有this.props.provider[0].netflixAnimeT动漫

但是,我想要输出:

Netflix有495种动漫

由于我希望它根据用户的评分等动态变化,我该如何更改JSX中的代码?谢谢。

reactjs state jsx concat string-concatenation
1个回答
0
投票

只需替换


0
投票

您的用法有误

© www.soinside.com 2019 - 2024. All rights reserved.