oldVersion
只读特性在
IDBVersionChangeEvent
interface returns the old version number of the database.
When the opened database doesn't exist yet, the value of
oldVersion
为 0。
var oldVersion = IDBVersionChangeEvent.oldVersion
A 64 位整数 .
var dbName = "sampleDB";
var dbVersion = 2;
var request = indexedDB.open(dbName, dbVersion);
request.onupgradeneeded = function(e) {
var db = request.result;
if (e.oldVersion < 1) {
db.createObjectStore("store1");
}
if (e.oldVersion < 2) {
db.deleteObjectStore("store1");
db.createObjectStore("store2");
}
// etc. for version < 3, 4...
};
| 规范 | 状态 | 注释 |
|---|---|---|
|
索引数据库 API 2.0
The definition of 'oldVersion' in that specification. |
推荐 | |
|
索引数据库 API 草案
The definition of 'oldVersion' in that specification. |
推荐 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
oldVersion
|
Chrome
24
|
Edge 12 |
Firefox
16
|
IE 部分支持 10 | Opera 15 | Safari 7 |
WebView Android
Yes
|
Chrome Android
25
|
Firefox Android 22 | Opera Android 14 | Safari iOS 8 |
Samsung Internet Android
1.5
|
完整支持
部分支持
要求使用供应商前缀或不同名称。
IDBDatabase
IDBTransaction
IDBKeyRange
IDBObjectStore
IDBCursor
IDBVersionChangeEvent
newVersion
oldVersion
version
IDBCursor
IDBCursorSync
IDBCursorWithValue
IDBDatabase
IDBDatabaseException
IDBDatabaseSync
IDBEnvironment
IDBEnvironmentSync
IDBFactory
IDBFactorySync
IDBIndex
IDBIndexSync
IDBKeyRange
IDBObjectStore
IDBObjectStoreSync
IDBOpenDBRequest
IDBRequest
IDBTransaction
IDBTransactionSync
IDBVersionChangeRequest