TypeError: Cannot read property 'openDatabase' of undefined

前端 未结 2 1761
青春惊慌失措
青春惊慌失措 2020-12-30 08:22

I want to work with sqlite with cordova framework for the first time. As I\'ve read on a tutorial I should use ngcordova like this:

var db = null;
app.contro         


        
2条回答
  •  失恋的感觉
    2020-12-30 09:03

    You might take a look at this tutorial:

    https://www.thepolyglotdeveloper.com/2014/11/use-sqlite-instead-local-storage-ionic-framework/

    When you see this error:

    TypeError: Cannot read property 'openDatabase' of undefined

    It is happening for one of a few reasons:

    1. You are not wrapping the $cordovaSQLite methods in the $ionicPlatform.ready() function.
    2. You are trying to test this native plugin from a web browser.
    3. You have not actually installed the base SQLite plugin into your project.

    The most common reasons for this error are #1 and #2. Native plugins, must be used only after the application is confirmed ready, thus the $ionicPlatform.ready() method. Since native plugins use native code, you cannot test them from your web browser.

    Read through the tutorial I linked because it should help you.

    Regards,

提交回复
热议问题