浏览器内置数据库
// 数据库demo
var testDB = window.indexedDB.open("testDB", 4);
var db;
testDB.onsuccess = function(event){
console.log("成功打开DB");
db = event.target.result;
//创建表
var objectStore = database.createObjectStore("students", { keyPath: rollNo });
//创建事物
var tran = db.transaction(["students"],"readwrite");
//获取表
var objectStore = tran.objectStore("students");
//往表添加数据
objectStore.add({rollNo: '1', name: 'mxp'});
//根据主键获取数据
var mxp = objectStore.get('1');
//获取成功回调
mxp.onsuccess = function(event){
console.log("Name : "+mxp.result.name);
};
}