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