Uncaught TypeError: Cannot read property 'openDatabase' of undefined

Uncaught TypeError: Cannot read property 'openDatabase' of undefined

我想第一次使用带有 cordova 框架的 sqlite。正如我在教程中读到的那样,我应该像这样使用 ngcordova:

  if (window.cordova)
     {
     db = $cordovaSQLite.openDB({ name: "littlebird.db" }); //device
     }
    else
     {
            db = window.openDatabase("littlebird.db", '1', 'littlebird', 1024 * 1024 * 100); // browser
     }

        $cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS mobileContact (id integer primary key, name text, mobile text,exit integer)");

但在部署时遇到问题

Uncaught TypeError: Cannot read property 'openDatabase' of undefined ng-cordova.min.js (9,20659)

编辑:

指定位置解决问题:

db = $cordovaSQLite.openDB({ 名称: "DBname.db" ,位置:'?'});

(查看此答案的评论 post 了解更多详情。)