[英]React Js : How can i use index number to disable button ( if index = 4 then disable button )
我想你在你的退貨聲明中尋找這樣的東西:
<Button
className="btn-info btn-sm"
type="button"
onClick={(e) => clicked(e)}
disabled={locations.length >= 4}
>
Add Address
</Button>
我認為您想使用 map.size() 作為禁用條件而不是索引中的地址數。
請注意,我一直在使用Bootstrap組件,因此該按鈕是一個嵌入式小部件。 如果您不使用 UI 小部件庫,那么您應該考慮使用它來簡化操作。
if(locations.length < 4) { <button type="button"> Add </button> }
所以基本上按鈕會根據條件是真還是假來顯示或消失。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.