这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
query()
方法在
LockManager
interface returns a
Promise
which resolves with an object containing information about held and pending locks.
var promise<LockManagerSnapshot> = LockManager.query()
None.
A
Promise
that resolves with a
LockManagerSnapshot
containing the following properties.
held
: An array of
锁
objects for held locks.
pending
: An array of
锁
objects for pending lock requests.
const state = await navigator.locks.query();
for (const lock of state.held) {
console.log(`held lock: name ${lock.name}, mode ${lock.mode}`);
}
for (const request of state.pending) {
console.log(`requested lock: name ${request.name}, mode ${request.mode}`);
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Web Locks API
The definition of 'query()' in that specification. |
草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
query
|
Chrome 69 | Edge ≤79 | Firefox ? | IE ? | Opera 56 | Safari ? | WebView Android 69 | Chrome Android 69 | Firefox Android ? | Opera Android 48 | Safari iOS ? | Samsung Internet Android 10.0 |
完整支持
兼容性未知
实验。期望将来行为有所改变。
LockManager
query()
request()