我有这个小代码片段 <Calendar style={{ height: 600, width: "120%" }} eventPropGetter={(event, start, end, isSelected) => { var backgroundColor = "#000000"; console.log(event.estado); console.log(isSelected); if (event.estado === 0 && isSelected === false) console.log("here"); if (event.estado === 0 && isSelected === true) backgroundColor = "#4d4dff"; if (event.estado === 2 && isSelected === true) backgroundColor = "#ff8c1a"; if (event.estado === 2 && isSelected === false) backgroundColor = "#b35900"; return { style: { backgroundColor } }; }}console.log(event.estado) 吐出 0console.log(isSelected) 吐出 false但是,console.log("here") 永远不会被触发。由于我是 JS 新手,我假设 JS 评估真实性的方式有些古怪,我不知道任何帮助将不胜感激
3 回答
呼唤远方
TA贡献1856条经验 获得超11个赞
根据下面的 html 文档,类型和值应该相同。请检查 isSelected 的类型是否相同。
使用 === 运算符时,布尔值不相等,因为 === 运算符要求类型和值都相等
添加回答
举报
0/150
提交
取消
