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

IDBLocaleAwareKeyRange 接口在 IndexedDB API is a Firefox-specific version of IDBKeyRange — it functions in exactly the same fashion, and has the same properties and methods, but it is intended for use with IDBIndex objects when the original index had a locale value specified upon its creation (see createIndex() 's optionalParameters ) — that is, it has locale aware sorting 被启用。

方法

This interface inherits all the methods of its parent interface, IDBKeyRange .

特性

This interface inherits all the properties of its parent interface, IDBKeyRange .

Bear in mind however that IDBLocaleAwareKeyRange has its own implementation of IDBKeyRange.bound . This is because when you use bound() , it checks if lower bound < upper bound, and throws an exception if that’s not the case. With locale-aware indexes, the meaning of < depends on the locale, so for example in Lithuanian Y is sorted between I and K. The only difference between IDBKeyRange and IDBLocaleAwareKeyRange is that the latter doesn’t do the aforementioned check.

Developers should always use IDBLocaleAwareKeyRange when dealing with locale-aware indexes.

范例

function displayData() {
  var keyRangeValue = IDBLocaleAwareKeyRange.bound("A", "F");
  var transaction = db.transaction(['fThings'], 'readonly');
  var objectStore = transaction.objectStore('fThings');
  var myIndex = objectStore.index('lName');
  myIndex.openCursor(keyRangeValue).onsuccess = function(event) {
    var cursor = event.target.result;
    if(cursor) {
      var tableRow = document.createElement('tr');
      tableRow.innerHTML =   '<td>' + cursor.value.id + '</td>'
                           + '<td>' + cursor.value.lName + '</td>'
                           + '<td>' + cursor.value.fName + '</td>'
                           + '<td>' + cursor.value.jTitle + '</td>'
                           + '<td>' + cursor.value.company + '</td>'
                           + '<td>' + cursor.value.eMail + '</td>'
                           + '<td>' + cursor.value.phone + '</td>'
                           + '<td>' + cursor.value.age + '</td>';
      tableEntry.appendChild(tableRow);
      cursor.continue();
    } else {
      console.log('Entries all displayed.');
    }
  };
};
					

规范

Not currently part of any specification.

浏览器兼容性

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
IDBLocaleAwareKeyRange 非标 Chrome 不支持 No Edge 不支持 No Firefox 43 Disabled
43 Disabled
Disabled From version 43: this feature is behind the dom.indexedDB.experimental preference. To change preferences in Firefox, visit about:config.
IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 43 Disabled
43 Disabled
Disabled From version 43: this feature is behind the dom.indexedDB.experimental preference. To change preferences in Firefox, visit about:config.
Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

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

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

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

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改: