如果两个条件为真,我想显示工具提示。 <LikelihoodIndicatorRefi likelihood={ props.props.approvalChance_NewLoan } > {console.log(props.props.approvalChance_NewLoan === 'Less Likely' && props.props.approvalChance_Combined === 'Less Likely')} {(props.props.approvalChance_NewLoan === 'Less Likely' && props.props.approvalChance_Combined === 'Less Likely' && <SmartTooltip wrapperCssClass="option-detail-tooltip" ctaLabel="How do I increase my chances?"> <h3>Less Likely</h3> <p> Want to improve your chnace of getting this loan? Try increasing the time to pay it back over.Or you could try asking for less money. </p> </SmartTooltip>)} </LikelihoodIndicatorRefi> <LikelihoodIndicatorRefi likelihood={ props.props.approvalChance_NewLoan } > {console.log(props.props.approvalChance_NewLoan === 'Less Likely' && props.props.approvalChance_Combined === 'Less Likely')} {(props.props.approvalChance_NewLoan === 'Less Likely' && props.props.approvalChance_Combined === 'Less Likely' && <SmartTooltip wrapperCssClass="option-detail-tooltip" ctaLabel="How do I increase my chances?"> <h3>Less Likely</h3> <p> Want to improve your chnace of getting this loan? Try increasing the time to pay it back over.Or you could try asking for less money. </p> </SmartTooltip>)} </LikelihoodIndicatorRefi>
2 回答
青春有我
TA贡献1784条经验 获得超8个赞
尝试
{(props.props.approvalChance_NewLoan === 'Less Likely' &&
props.props.approvalChance_Combined === 'Less Likely' ?
<SmartTooltip wrapperCssClass="option-detail-tooltip" ctaLabel="How do I increase my chances?">
<h3>Less Likely</h3>
<p>
Want to improve your chnace of getting this loan? Try increasing the time to pay it back over.Or you could try asking for less money.
</p>
</SmartTooltip>) : null}
墨色风雨
TA贡献1853条经验 获得超6个赞
简单地链接&&
表达式,如果之前的所有表达式都为真,它总是会计算到最后一个表达式。所以bool && bool && <Component />
将足以显示它。如果您将它作为 JSX 树中的第一个元素,那么您应该<></>
在条件周围添加React.Fragment 以获得有效的根元素。
添加回答
举报
0/150
提交
取消