文章詳情頁
javascript - 根據不同數據顯示不同內容
瀏覽:148日期:2023-02-28 09:44:34
問題描述
我的planCount,是不固定的,我應該怎樣寫比如
planCount==1; 顯示 一級planCount==2; 顯示 二級planCount==3; 顯示 三級
問題解答
回答1:{this.props.data.planCount === 1 ? '一級' : (this.props.data.planCount === 2 ? '二級' : '三級')}回答2:
<td className='width-w-10'>{this.props.data.planCount}級</td>
如果要將數字轉化成中文就需要額外處理了 不超過10的話可以這樣
const level = [’一’, ’二’, ’三’, ’四’, ’五’, ’六’, ’七’, ’八’, ’九’, ’十’]<td className='width-w-10'>{level[this.props.data.planCount - 1]}級</td>
標簽:
JavaScript
相關文章:
排行榜
