此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

ServiceWorkerRegistration:scope 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2018年4月.

安全上下文: 此特性仅在一些支持的浏览器安全上下文(HTTPS)中可用。

备注: 此特性在 Web Worker 中可用。

ServiceWorkerRegistration 接口的只读属性 scope 返回一个字符串,该字符串表示定义了 service worker 注册作用域的 URL;即 service worker 可以控制的 URL 范围。此值通过调用 ServiceWorkerContainer.register()(用于注册 service worker)时指定的 scope 参数进行设置。

返回一个表示定义 service worker 注册作用域的 URL 的字符串。

规范

Specification
Service Workers Nightly
# service-worker-registration-scope

浏览器兼容性

参见