ionic-native sqlite 插件5.x版的在ionic3.x上报错 cannot read property 'split' of undefined

话说ionic是真坑,文档质量就很差,版本兼容性也不好。最近要搞ionic sqlite开发,期间遇到问题:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'split' of undefined
TypeError: Cannot read property 'split' of undefined

根据报错发现是调用 sqlite.create 方法时报的,

在stackoverflow上找到了答案

https://stackoverflow.com/questions/56223985/cannot-read-property-split-of-undefined-sqlite-ionic-v3-sqlite

在ionic3.x上使用 ionic-native/sqlite 5.x 就会报这个错。

解决方法:

卸载 ionic-native/sqlite 5.x,

npm uninstall -S @ionic-native/sqlite

安装4.x.x的版本

npm i -S @ionic-native/sqlite@^4.0.0

并且要将

import { SQLite, SQLiteObject } from '@ionic-native/sqlite/ngx';

改为

import { SQLite, SQLiteObject } from '@ionic-native/sqlite';

 

posted @ 2019-08-17 20:40  johnjackson  阅读(491)  评论(0编辑  收藏  举报