From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/request/credentials/index.html | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 files/zh-cn/web/api/request/credentials/index.html (limited to 'files/zh-cn/web/api/request/credentials/index.html') diff --git a/files/zh-cn/web/api/request/credentials/index.html b/files/zh-cn/web/api/request/credentials/index.html new file mode 100644 index 0000000000..f7a57ad6c0 --- /dev/null +++ b/files/zh-cn/web/api/request/credentials/index.html @@ -0,0 +1,64 @@ +--- +title: Request.credentials +slug: Web/API/Request/credentials +tags: + - API + - Fetch + - 属性 + - 证书 + - 请求 +translation_of: Web/API/Request/credentials +--- +
{{APIRef("Fetch")}}
+ +

credentials 是{{domxref("Request")}}接口的只读属性,用于表示用户代理是否应该在跨域请求的情况下从其他域发送cookies。这与XHR的withCredentials 标志相似,不同的是有三个可选值(后者是两个):

+ + + +

语法

+ +
var myCred = request.credentials;
+ +

Value

+ +

A {{domxref("RequestCredentials")}} value.

+ +

举例

+ +

在以下代码中,我们使用{{domxref("Request.Request()")}}创建了一个新的request(为了一个与脚本在同一目录下的图片文件), 接着将request credentials存入一个变量:

+ +
var myRequest = new Request('flowers.jpg');
+var myCred = myRequest.credentials; // returns "same-origin" by default
+ +

说明

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Fetch','#dom-request-credentials','credentials')}}{{Spec2('Fetch')}}Initial definition
+ +

浏览器兼容性

+ +

{{Compat("api.Request.credentials")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf