HTML5 IndexedDB示例
以下函数是IndexedDB添加数据的示例:
function add() {
var request = db.transaction(["employee"], "readwrite")
.objectStore("employee")
.add({ id: "001", name: "Amit", age: 28, email: "demo1@example.com" });
request.onsuccess = function(event) {
alert("Amit已添加到您的数据库。");
};
request.onerror = function(event) {
alert("Unable to add data\r\nAmit is already exist in your database! ");
}
}上面,我们在数据库中添加了以下详细信息:
const employeeData = [
{ id: "001", name: "Amit", age: 28, email: "demo1@example.com" },
];热门推荐
10 新娘对伴娘祝福语简短
11 生日祝福语男孩 简短独特
12 恭喜订婚的祝福语简短
13 酒店客人祝福语简短
14 幼儿住院祝福语老师简短
15 老师新婚快乐祝福语简短
16 对别人新年祝福语简短
17 庆祝论坛周年祝福语简短
18 姨父生日祝福语简短精辟