Antd之三元表达式判断代码备忘

{
    Object.keys(Version || Object).map(key => {
        return (

            ' : ' + 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}
            />

        )
    })
}

你可能感兴趣的:(ReactJS)