这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

安全上下文
此特征只可用于 安全上下文 (HTTPS),在某些或所有 支持浏览器 .

The interface of the 证书管理 API provides information about a username/password pair. In supporting browsers an instance of this class may be passed in the credential 成员对于 init object for global fetch .

注意: This interface is restricted to top-level contexts and cannot be used from an <iframe> .

构造函数

PasswordCredential() 安全上下文
创建新的 PasswordCredential 对象。

特性

Inherits properties from its ancestor, Credential .

PasswordCredential.additionalData 安全上下文
One of a FormData instance, a URLSearchParams instance, or null. The data in the objects will be added to the request body and sent to the remote endpoint with the credentials.
PasswordCredential.iconURL 只读 安全上下文
USVString containing a URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication.
PasswordCredential.idName 安全上下文
USVString containing the name that will be used for the ID field when submitting the current object to a remote endpoint via fetch . This property defaults to 'username', but may be overridden to match whatever the backend service expects.
PasswordCredential.name 只读 安全上下文
USVString containing a human-readable public name for display in a credential chooser.
PasswordCredential.password 只读 安全上下文
USVString containing the password of the credential.
PasswordCredential.passwordName 安全上下文
USVString representing the name that will be used for the password field when submitting the current object to a remote endpoint via fetch . This property defaults to 'password', but may be overridden to match whatever the backend service expects.

事件处理程序

None.

方法

None.

范例

var cred = new PasswordCredential({
  id: id,
  password: password,
  name: name,
  iconURL: iconUrl
});
navigator.credentials.store(cred)
 .then(function() {
 // Do something else.
});
					

规范

规范 状态 注释
Credential Management Level 1 工作草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
PasswordCredential Chrome 51 Edge ≤79 Firefox ? IE ? Opera Yes Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0
PasswordCredential() 构造函数 非标 Chrome 51 Edge ≤79 Firefox ? IE ? Opera ? Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0
additionalData 弃用 Chrome 51 Edge ≤79 Firefox ? IE ? Opera ? Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0
iconURL Chrome 52 Edge ≤79 Firefox ? IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 6.0
idName 弃用 Chrome 51 Edge ≤79 Firefox ? IE ? Opera ? Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0
名称 Chrome 52 Edge ≤79 Firefox ? IE ? Opera Yes Safari ? WebView Android 52 Chrome Android 52 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 6.0
password Chrome 60 Edge ≤79 Firefox ? IE ? Opera Yes Safari ? WebView Android 60 Chrome Android 60 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 8.0
passwordName 弃用 Chrome 51 Edge ≤79 Firefox ? IE ? Opera ? Safari ? WebView Android 51 Chrome Android 51 Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android 5.0

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

元数据

  • 最后修改: