三元运算符简单的非空验证

$('.operationStatus').text(!result.data.customer.operationStatus?"无":result.data.customer.operationStatus);

页面渲染的时候会经常碰到 null  “”  Undefined   等 需要验证,三元可以直接方便简单的判断渲染!

猜你喜欢

转载自blog.csdn.net/qq_42221334/article/details/84662529
今日推荐