我有這個值,我想覆蓋它的一個屬性。我嘗試了以下方法:fetchOptions: Readonly<HttpFetchOptionsWithPath>((fetchOptions as Writable<HttpFetchOptionsWithPath>).headers as Writable<any>) = { 'new-value': '123', ...(fetchOptions.headers || {}), };但仍然收到錯誤。TypeError: Cannot assign to read only property 'headers' of object '#<Request>'執行的 js 代碼如下所示:fetchOptions.headers = __assign({ 'new-value': '123' }, (fetchOptions.headers || {}));任何想法,我在這里做錯了什么?
如何修改只讀值?
慕桂英546537
2022-08-27 14:39:43