URLPattern:hash 屬性
注意:此功能在 Web Workers 中可用。
hash 是 URLPattern 介面的一個只讀屬性,它是一個字串,包含用於匹配 URL 片段部分模式。
這是傳遞給建構函式的 hash 模式的規範化值,或者是傳遞給建構函式的從 baseURL 繼承的值,或者是預設值 ("*"),該預設值匹配任何 hash。
值
字串。
示例
基本用法
下面的示例建立了一個 URLPattern 物件,其中 hash 部分為 books/:id,並記錄了該屬性。此模式匹配任何以 books/ 開頭並以任意字串識別符號結尾的片段。
js
const pattern = new URLPattern("https://example.org#books/:id");
console.log(pattern.hash); // 'books/:id'
console.log(pattern.test("https://example.org#books/123")); // true
規範
| 規範 |
|---|
| URL 模式 # dom-urlpattern-hash |
瀏覽器相容性
載入中…