这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
locale
只读特性在
IDBIndex
interface returns the locale of the index (for example
en-US
,或
pl
) if it had a
locale
value specified upon its creation (see
createIndex()
's optionalParameters
.) Note that this property always returns the current locale being used in this index, in other words, it never returns
"auto"
.
var myIndex = objectStore.index('index');
console.log(myIndex.locale);
A
DOMString
.
In the following example we open a transaction and an object store, then get the index
lName
from a simple contacts database. We then open a basic cursor on the index using
IDBIndex.openCursor
— this works the same as opening a cursor directly on an
ObjectStore
使用
IDBObjectStore.openCursor
except that the returned records are sorted based on the index, not the primary key.
locale
value is logged to the console.
function displayDataByIndex() {
tableEntry.innerHTML = '';
var transaction = db.transaction(['contactsList'], 'readonly');
var objectStore = transaction.objectStore('contactsList');
var myIndex = objectStore.index('lName');
console.log(myIndex.locale);
myIndex.openCursor().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.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
locale
非标
|
Chrome 不支持 No | Edge 不支持 No | Firefox 43 | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 43 | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 不支持 No |
完整支持
不支持
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
IDBDatabase
IDBTransaction
IDBKeyRange
IDBObjectStore
IDBCursor
IDBIndex
isAutoLocale
keyPath
locale
multiEntry
名称
objectStore
unique
IDBCursor
IDBCursorSync
IDBCursorWithValue
IDBDatabase
IDBDatabaseException
IDBDatabaseSync
IDBEnvironment
IDBEnvironmentSync
IDBFactory
IDBFactorySync
IDBIndexSync
IDBKeyRange
IDBObjectStore
IDBObjectStoreSync
IDBOpenDBRequest
IDBRequest
IDBTransaction
IDBTransactionSync
IDBVersionChangeEvent
IDBVersionChangeRequest