search

Home  >  Q&A  >  body text

javascript - display different content based on different data


My planCount is not fixed, how should I write it, for example

planCount==1; Display level one
planCount==2; Display level two
planCount==3; Display level three

代言代言2782 days ago1184

reply all(2)I'll reply

  • 滿天的星座

    滿天的星座2017-07-05 11:01:11

    {this.props.data.planCount === 1 ? "一级" : (this.props.data.planCount === 2 ? "二级" : "三级")}

    reply
    0
  • 为情所困

    为情所困2017-07-05 11:01:11

    <td className="width-w-10">{this.props.data.planCount}级</td>

    If you want to convert the numbers into Chinese, additional processing is required. If it does not exceed 10, you can do this

    const level = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十']
    <td className="width-w-10">{level[this.props.data.planCount - 1]}级</td>

    reply
    0
  • Cancelreply