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 毕业祝福语简短给同学