我想添加或從html輸入元素中刪除屬性。更改輸入元素的只讀屬性:ReactJS
什麼,我所做的就是這樣的:
constructor(props) {
super(props);
this.state = {inputState: 'readOnly'};
}
而且渲染功能:
<input className="form-control" type="text" value={floor} {...this.state.inputState} />
正如你可以看到我想要設置的輸入元素上參考「readOnly」屬性。 但現在我得到它說的錯誤:
未知道具
0
,1
,2
,3
,4
,5
,6
,7
的標籤。從元素中移除這些道具
當用戶點擊輸入元素時,它應該變成可編輯的,所以我想動態地改變這個屬性。
但我該怎麼做?
如果你真的想傳播的狀態。簡單地做到:'' – mersocarlin