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 has been added to your database.");
   };
   request.onerror = function(event) {
      alert("Unable to add data\r
Amit is already exist in your database! ");    } }

在上面,我们在数据库中添加了以下详细信息

const employeeData = [
   { id: "001", name: "Amit", age: 28, email: "demo1@example.com" },
];

更新日期:29-1-2020

193 次浏览

开启你的 职业

通过完成课程获得认证

开始
广告
© . All rights reserved.