我有一個提交表單。單擊它時,我創建一個物件將這些資料發送到 POST。
所以我有 saveEntity const:
const saveEntity = (event, errors, values) => {
// this is the const that is signed as error:
const valoreComune: any = comCod ? { comCod: { comCod: comCod } } : personEntity.comCod ? { comCod: { comCod: personEntity.comCod.comCod } } : { comCod: null };
//....
const entity = { // this is the object that I pass to post
// ....
valoreComune
}
}
我需要重新創建這個物件結構:
comCod: {
comCod: value
}
或者
comCod: null
現在我收到此錯誤:
預期屬性簡寫物件-簡寫
現在通常我以這種方式直接解決寫作:
const entity = {
valoreComune
}
但它不起作用。我能怎么做?
uj5u.com熱心網友回復:
您應該為此部分使用物件速記語法:
{ comCod: { comCod: comCod } }
是這樣寫的:
{ comCod: { comCod } }
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/340954.html
標籤:javascript 反应 打字稿
