Antd之三元表达式判断代码备忘
程序员文章站
2022-04-05 11:09:28
...
{
Object.keys(Version || Object).map(key => {
return (
<TreeNode
title={key + ' : ' + this.state.gVersion && key === 'Version' ?
//正确写法:判断条件需要加括号
((this.state.gVersion.value === undefined) ? key + ' : ' + Version[key] : key + ' : ' + this.state.gVersion.value) :
//错误写法:页面无法显示
(key + ' : ' + this.state.gUpstream.value === undefined ? Version[key] : this.state.gUpstream.value)}
key={key + '_' + Version[key] + '_' + key}
/>
)
})
}
推荐阅读