我的組件中有一個(gè)狀態(tài),我想在單擊保存按鈕并更改和刪除克隆的某些屬性然后發(fā)布到后端時(shí)克隆此狀態(tài),但是當(dāng)我更改克隆數(shù)組時(shí),原始狀態(tài)也會(huì)更改;我不知道該怎么做我追蹤了克隆陣列的所有方法,但所有方法都沒有幫助我;以下是我的代碼:... const [steps , setSteps] = useState([ { id: 1, // content: "item 1 content", subItems: [ { id: 10, isNew : false , hasWorkflow : true , title : 'SubItem 10 content' , approverType : 1, approverId : 0 , }, { id: 11, isNew : false , hasWorkflow : true , title : 'SubItem 11 content' , approverType : 2, approverId : 1 , } ] }, { id: 2, // content: "item 2 content", subItems: [ { id: 20, isNew : false , hasWorkflow : false , title : 'SubItem 20 content' , approverType : 2, approverId : 4 , }, { id: 21, isNew : false , hasWorkflow : false , title : 'SubItem 21 content' , approverType : 1, approverId : 3, } ] } , { id: 3, content: "item 3 content", subItems: [ { id: 55, isNew : false , hasWorkflow : false , title : 'SubItem 20 content' , approverType : 2, approverId : 6 , }, { id: 66, isNew : false , hasWorkflow : false , title : 'SubItem 21 content' , approverType : 2, approverId : 4 , } ] } ]);....
如何更改數(shù)組的克隆而不更改 reactjs 中的原始數(shù)組
海綿寶寶撒
2023-02-17 16:01:29