admin 管理员组

文章数量: 1184232

!!的用法

 

!''=true!undefined=true!null=true!123=false!'string'=false

!转换成布尔类型,空字符串、undefined和null取反都为false,其余都为true

!!常常用来做类型判断

if(!!a){//a!=null&&typeof(a)!=undefined&&a!=''//a有内容才执行的代码...  
}
let alertCls = classNames(prefixCls, {[`${prefixCls}-${type}`]: true,[`${prefixCls}-with-description`]: !!description,[`${prefixCls}-no-icon`]: !showIcon,}, className);

ant-design的源码有大量实现

项目中的案例

本文标签: 的用法