文章详情页
javascript - 根据不同数据显示不同内容
浏览:320日期: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
相关文章:
1. html - 竖线怎么实现2. javascript - vue组件通过eventBus通信时,报错a.$on is not a function3. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””4. php - 两个表数据怎么插到一个模板中,并按时间排序?5. javascript - 如何找到页面中js function对应的源代码?6. docker - 如何修改运行中容器的配置7. 编辑管理员信息时,为什么没有修改过的内容会为空?8. 求解决方法:Parse error: syntax error, unexpected9. html5 - 如何禁止百度转码?10. 网页爬虫 - python爬虫用BeautifulSoup爬取<s>元素并写入字典,但某些div下没有这一元素,导致自动写入下一条,如何解决?
排行榜

网公网安备