JSX做表达式判断时候,需要强转为boolean类型,如:

426 阅读1分钟

render() { const b = 0; return

{ !!b &&
这是一段文本
}

} 如果不使用 !!b 进行强转数据类型,会在页面里面输出 0。