AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
## ResponseOptions Creates a response options object to be optionally provided when instantiating a `Response`. This class is based on the ResponseInit description in the Fetch Spec. All values are null by default. Typical defaults can be found in the `BaseResponseOptions` class, which sub-classes `ResponseOptions`. This class may be used in tests to build `Responses` for mock responses (see `MockBackend`). 示例: ```typescript import {ResponseOptions, Response} from '@angular/http'; var options = new ResponseOptions({ body: '{"name":"Jeff"}' }); var res = new Response(options); console.log('res.json():', res.json()); // Object {name: "Jeff"} ``` ### 类定义 ```typescript class ResponseOptions { constructor({body, status, headers, statusText, type, url}?: ResponseOptionsArgs) body : string|Object|ArrayBuffer|Blob status : number headers : Headers url : string merge(options?: ResponseOptionsArgs) : ResponseOptions } ``` ### 属性 - body : `string` | `Object` | `ArrayBuffer` | `Blob` 表示`Response`响应体的数据类型:String, Object, ArrayBuffer or Blob - status : `number` 状态码 - headers : `Headers` 请求体头部 - url : `string` - merge(options?: `ResponseOptionsArgs`) : `ResponseOptions` Creates a copy of the ResponseOptions instance, using the optional input as values to override existing values. This method will not change the values of the instance on which it is being called. This may be useful when sharing a base ResponseOptions object inside tests, where certain properties may ```typescript import {ResponseOptions, Response} from '@angular/http'; var options = new ResponseOptions({ body: {name: 'Jeff'} }); var res = new Response(options.merge({ url: 'https://google.com' })); console.log('options.url:', options.url); // null console.log('res.json():', res.json()); // Object {name: "Jeff"} console.log('res.url:', res.url); // https://google.com ```