webSql 本地数据库

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<script>
    //1.打开数据库
    /**
     * openDatabase() 方法对应的五个参数说明:

     数据库名称
     版本号
     描述文本
     数据库大小
     创建回调
     第五个参数,创建回调会在创建数据库后被调用。
     */

    var db = openDatabase('todoList', '1.0', 'todoList项目前端数据库', 2 * 1024 * 1024);

    //2.执行查询创建 ,创建了一个表明为 todoList
//    db.transaction(function (tx) {
//        tx.executeSql('CREATE TABLE IF NOT EXISTS todoList (id unique, title,time,status)');
//    });

    //3.在todoList 数据表中插入数据
    db.transaction(function (tx) {
        tx.executeSql('INSERT INTO todoList (id, title ,time ,status) VALUES (3, "睡觉" , "2018-8-21" , false)');
    });
</script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_42400955/article/details/84204689