养猪场老板 2020-08-04 16:35 采纳率: 100%
浏览 555
已采纳

React 与运算符 && 多层级的条件判断

图片说明
{ type == 0 &&


礼金价: ¥
{ item.welfare_price }

}
{ (type == 0 && item.publicCoupons != null) &&

¥{ item.publicCoupons.price }

}
{ (type == 0 && item.per_face != null) &&

预估
淘礼金¥{ item.per_face }

}
请问这种情况如何简化 不想重复判断type字段

  • 写回答

3条回答 默认 最新

  • a1765659645 2020-08-06 17:54
    关注

    {type == 0 && (
    <>


    礼金价:¥
    {item.selfare_price}

    {Item.publicCoupons !==null && (

    )}
    {Item.per_face && (

    )}
    </>
    )}

    图片说明

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?