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

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

问题描述

我在ngCordova插件cordovaSQLite中有1个问题。代码如下:

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

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

我在浏览器中使用离子服务运行项目。

i'm using "ionic serve" for run project in browser.

错误:
未捕获TypeError:无法读取undefinedng-cordova.js的属性'openDatabase':5058

error: Uncaught TypeError: Cannot read property 'openDatabase' of undefinedng-cordova.js:5058

openDBapp.js: 27

openDBapp.js:27

(匿名函数)ionic.bundle.js:37388

(anonymous function)ionic.bundle.js:37388

(匿名函数)ionic.bundle。 JS:2241

(anonymous function)ionic.bundle.js:2241

onPlatformReadyionic.bundle.js:2220

onPlatformReadyionic.bundle.js:2220

onWindowLoad

onWindowLoad

[主要错误] http://i.stack.imgur.com/Yctpl .png

你能帮我吗?

推荐答案

用户jonnie在他的答案中说明

As stated by user jonnie in his answer


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

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


你可以替换cordova插件使用窗口来使用websql数据库,而不是sqlitePlugin.openDatabase(),你可以使用window.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 cordovaSQLite插件错误无法读取未定义的属性'openDatabase'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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