cuốn sách gpt4 ai đã làm

html - 如何在 React 中执行多个 if else 语句?

In lại Tác giả: Walker 123 更新时间:2023-11-28 02:43:21 48 4
mua khóa gpt4 Nike

所以我正在尝试在 React 中创建一个类似于以下内容的 if else 语句...

(其中 aNumber 是任意数字)

if(aNumber < 5){
show a picture
}else if (aNumber < 10){
show a different picture
}else if (aNumber < 15){
show another different picture
}khác{
show a some other 4th picture
}

在我的表中 this.state.sWA1 返回风速,所以如果它高于某个值我想根据风速的高低显示不同的图片

{this.state.sWA1 > '15' ?  :  }

这目前有效,但我似乎只能找到一个 if else 语句的帮助,而不是几个 if else 语句,任何人都可以提供帮助或建议替代方法吗?

Cảm ơn!

câu trả lời hay nhất

它叫做 conditional rendering


{ this.state.sWA1>15 &&

//show picture
}
{ this.state.sWA1>5 && this.state.sWA1<15

//show picture
}

关于html - 如何在 React 中执行多个 if else 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42577139/

48 4 0
Walker 123
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress