sqlite – TypeError:无法读取未定义的属性“openDatabase”
我想第一次与cordova框架一起使用sqlite.正如我在教程中阅读的,我应该使用ngcordova:
var db = null; app.controller('mainCtrl',function ($scope,$ionicSideMenuDelegate) { $scope.toggleLeft = function () { $ionicSideMenuDelegate.toggleLeft(); } $scope.toggleRight = function () { $ionicSideMenuDelegate.toggleRight(); } }) .controller('home_ctrl',$cordovaSQLite) { db = $cordovaSQLite.openDB({name: "my.db"}); //db = $window.opendb({name: "my.db"}); $cordovaSQLite.execute(db,"CREATE TABLE IF NOT EXISTS people(id integer primary key,firstname text,lastname text)") }) ; 当我运行这个代码一个错误说: TypeError: Cannot read property 'openDatabase' of undefined 在一些这样的文章:How do I use the ngCordova sqlite service and the Cordova-SQLitePlugin with Ionic Framework? https://www.thepolyglotdeveloper.com/2014/11/use-sqlite-instead-local-storage-ionic-framework/ 当你看到这个错误: TypeError:无法读取未定义的属性“openDatabase” 这是发生的原因之一: >你没有在$ionPlatform.ready()函数中包装$cordovaSQLite方法. 这个错误最常见的原因是#1和#2.本地插件,只有在应用程序确认后才能使用,因此$ionPlatform.ready()方法.由于本地插件使用本机代码,因此无法从Web浏览器中测试. 阅读我链接的教程,因为它应该帮助你. 问候, (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 让sama5d3_xplained支持spi flash
- Flex复制内容到剪切板
- 案例学习BlazeDS+Spring之十五:Security Integration 101
- ruby-on-rails – 如何验证这两个值在Rails模型中不相等?
- 数组 – 如何强制抛出写数组,即使数组中只有一个元素?
- 依赖注入 – 如何在TYPO3 Extbase扩展中包含或自动加载外部
- 【React Native开发】React Native控件之Switch开关与Picke
- 深度学习中的五大正则化方法和七大优化策略
- ruby-on-rails – Rails 4 Devise 3.1.1 ActionController
- sqlite3数据的导入和导出