[英]multiple conditional if statement not working
I am working on a project for my wife's diabetes and I have a multiple conditional if statement that isn't working... I have preferences to choose from and it goes to the first one in the list... here is my code我正在为我妻子的糖尿病开展一个项目,并且我有一个不起作用的多个条件 if 语句......我有偏好可供选择,它进入列表中的第一个......这是我的代码
{this.state.preferences.timesPD === 3 &&
this.state.preferences.chkCarbs === true &&
this.state.preferences.chkInsulin === true ? (
<TableThree
add={this.add}
date={this.state.date}
sugarB={this.state.sugarB}
carbsB={this.state.carbsB}
insulinB={this.state.insulinB}
sugarL={this.state.sugarL}
carbsL={this.state.carbsL}
insulinL={this.state.insulinL}
sugarD={this.state.sugarD}
carbsD={this.state.carbsD}
insulinD={this.state.insulinD}
editIdx={this.state.editIdx}
startEditing={this.startEditing}
stopEditing={this.stopEditing}
handleChange={this.handleChange}
data={this.state.data}
header={[
{
name: "Sugar Count",
prop: "sugarB"
},
{
name: "Carbs",
prop: "carbsB"
},
{
name: "Insulin",
prop: "insulinB"
},
{
name: "Sugar Count",
prop: "sugarL"
},
{
name: "Carbs",
prop: "carbsL"
},
{
name: "Insulin",
prop: "insulinL"
},
{
name: "Sugar Count",
prop: "sugarD"
},
{
name: "Carbs",
prop: "carbsD"
},
{
name: "Insulin",
prop: "insulinB"
}
]}
/>
)}
what i'm wanting to do is display one table at a time depending on the options I select我想要做的是一次显示一张桌子,具体取决于我 select 的选项
At the end of your condition, replace在你的条件结束时,更换
this.state.preferences.chkInsulin === true ? (
by经过
this.state.preferences.chkInsulin === true && (
Full code:完整代码:
{this.state.preferences.timesPD === 3 &&
this.state.preferences.chkCarbs === true &&
this.state.preferences.chkInsulin === true && (
<TableThree
add={this.add}
date={this.state.date}
sugarB={this.state.sugarB}
carbsB={this.state.carbsB}
insulinB={this.state.insulinB}
sugarL={this.state.sugarL}
carbsL={this.state.carbsL}
insulinL={this.state.insulinL}
sugarD={this.state.sugarD}
carbsD={this.state.carbsD}
insulinD={this.state.insulinD}
editIdx={this.state.editIdx}
startEditing={this.startEditing}
stopEditing={this.stopEditing}
handleChange={this.handleChange}
data={this.state.data}
header={[
{
name: "Sugar Count",
prop: "sugarB"
},
{
name: "Carbs",
prop: "carbsB"
},
{
name: "Insulin",
prop: "insulinB"
},
{
name: "Sugar Count",
prop: "sugarL"
},
{
name: "Carbs",
prop: "carbsL"
},
{
name: "Insulin",
prop: "insulinL"
},
{
name: "Sugar Count",
prop: "sugarD"
},
{
name: "Carbs",
prop: "carbsD"
},
{
name: "Insulin",
prop: "insulinB"
}
]}
/>
)}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.