我在 reactjs 中有一个条件,它以+this.state.isCompleted我们为什么要写作+?
1 回答

慕森王
TA贡献1777条经验 获得超3个赞
是强制转换为number
const str = '1'
const bool = false
const fail = 'isNan?'
const num = +str
const numBool = +bool
const numFail = +fail
console.log(typeof num, typeof numBool, numFail)
添加回答
举报
0/150
提交
取消