需要重构三元组的帮助

问题描述 投票:-1回答:1

我做了这个三元运算符,它可以工作,但是我知道它会更好。如果有人可以帮助我重构此代码,那就太好了

disabled={ mainCurrency.code
              ? currency.code
                 ? currency.code === mainCurrency.code
                   ? true
                   : false
                 : true
               : true
          }
ternary
1个回答
0
投票

因此,如果未设置mainCurrency或未设置货币或mainCurrency等于currency,则它为true。写出来是

!mainCurrency.code || !currency.code || currency.code === mainCurrency.code
© www.soinside.com 2019 - 2024. All rights reserved.