當我嘗試啟用刪除按鈕時,盡管我為此添加了邏輯,但它不起作用。實際上,在添加以下刪除按鈕后,刪除按鈕始終處于啟用狀態(tài)。找不到問題。這是代碼:運動.js// initiallising statesconst [items1, setItems1] = useState({pageCount: '',field_names_state: [],toggle: false,elements: [],data_form: [],sports_id: '',buttonDisable: "0",}); const onRadioChange = (e) => {items1.sports_id = e.target.value;items1.buttonDisable="1";alert(items1.buttonDisable);};// mapping our fetched data and send them to Table_Sports.jsconst data1 = items1.elements.map((item) => (<Table_Sports key={item.sports_id} item={item} action={onRadioChange} />));<button type='button' disabled={items1.buttonDisable=="1"} onClick={(e) => handleDelete(e)}> Delete</button>Table_Sports.js <td> <input type='radio' // defaultValue={props.item.sports_id} defaultValue={props.} name='sports_id' onClick={(e) => props.action(e)} /> </td> <td> <input type='text' defaultValue={props.item.sports_name} name='sports_name' contentEditable='true' /> </td>
為什么單擊單選按鈕后按鈕啟用條件不起作用?
慕的地8271018
2023-01-06 16:23:18