文章詳情頁
javascript - 根據(jù)不同數(shù)據(jù)顯示不同內(nèi)容
瀏覽:131日期:2023-02-28 09:44:34
問題描述
我的planCount,是不固定的,我應(yīng)該怎樣寫比如
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>
如果要將數(shù)字轉(zhuǎn)化成中文就需要額外處理了 不超過10的話可以這樣
const level = [’一’, ’二’, ’三’, ’四’, ’五’, ’六’, ’七’, ’八’, ’九’, ’十’]<td className='width-w-10'>{level[this.props.data.planCount - 1]}級</td>
標(biāo)簽:
JavaScript
相關(guān)文章:
1. [python2]local variable referenced before assignment問題2. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時間會消失是什么情況?3. mysql - 如何在有自增id的情況下,讓其他某些字段能不重復(fù)插入4. python小白,關(guān)于函數(shù)問題5. django - Python error: [Errno 99] Cannot assign requested address6. angular.js - 百度支持_escaped_fragment_嗎?7. java - 線上應(yīng)用,如果數(shù)據(jù)庫操作失敗的話應(yīng)該如何處理?8. node.js - win 下 npm install 遇到了如下錯誤 會導(dǎo)致 無法 run dev么?9. python小白 關(guān)于類里面的方法獲取變量失敗的問題10. Python2中code.co_kwonlyargcount的等效寫法
排行榜

熱門標(biāo)簽