Ionic Cordova SQLite插件错误无法读取未定义的属性"openDatabase" [英] Ionic Cordova SQLite plugin error Cannot read property 'openDatabase' of undefined

查看:251
本文介绍了Ionic Cordova SQLite插件错误无法读取未定义的属性"openDatabase"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ngCordova插件cordovaSQLite中有1个问题.下面的代码:

I have 1 issue in ngCordova plugin cordovaSQLite. Below code:

var db = $cordovaSQLite.openDB({ name: "myDB.db" });

我在浏览器中使用ionic serve.

错误:

Uncaught TypeError: Cannot read property 'openDatabase' of undefinedng-cordova.js:5058 
openDBapp.js:27 
(anonymous function)ionic.bundle.js:37388 
(anonymous function)ionic.bundle.js:2241 
onPlatformReadyionic.bundle.js:2220 
onWindowLoad

能请你帮我吗?

推荐答案

用户jonnie在其答案中指出/p>

As stated by user jonnie in his answer

Cordova是特定于平台的,在运行离子服务时不起作用

Cordova is platform specific and doesn't work when you run ionic serve

您可以使用window替换cordova插件以使用websql数据库,因此可以使用window.openDatabase()代替sqlitePlugin.openDatabase()

you can replace the cordova plugin with window to use the websql databases so instead of sqlitePlugin.openDatabase() you can use window.openDatabase()

它应该可以在实际设备上正常工作.

It should work on actual devices just fine.

这篇关于Ionic Cordova SQLite插件错误无法读取未定义的属性"openDatabase"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆