为 Ionic4 Vue 安装 SQlite
Install SQlite for Ionic4 Vue
我正在尝试将 SQlite 添加到我的 ionic4 项目中,但出现安装错误。
我的 NPM 安装是这样的:
ionic cordova plugin add cordova-sqlite-storage
npm install @ionic-native/sqlite
//ionic plugin add cordova-sqlite-storage ==> this one makes error
在 main.js 中,我尝试了以下各项:
import SQLite from 'ionic-native';
import {SQLite} from 'ionic-native';
import SQLite from '@ionic-native/sqlite';
import {SQLite} from '@ionic-native/sqlite';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
以下是错误:a) npm 警告,b) 控制台错误,以及 c) Chrome main.js 检查员
这是来自 main.js 的代码(最后一行是一切都失败的地方)。
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App },
render : (h) => h(App),
mounted() {
this.storage = new SQLite();
*** 我将此问题标记为已回答,但似乎还没有答案。我会继续努力的。
@ionic/vue 仍处于测试阶段,团队 working on integrating it with the Vue CLI. They are also using Capacitor, not Cordova, as the official native bridge for this project. As such it is recommended to use Capacitor if at all possible. Should you go that route, their storage API 可以代替 SQLite。
如果您想继续使用 Cordova 项目,Ionic Storage 抽象将不可用,因此您将不得不完全绕过 Ionic。
使用 Cordova CLI 安装 plugin(不需要 @ionic-native/sqlite
):
cordova plugin add cordova-sqlite-storage
直接使用插件,例如
const db = window.sqlitePlugin.openDatabase({...})
db.executeSql('INSERT...', [...values], callbackFn, errorFn)
我正在尝试将 SQlite 添加到我的 ionic4 项目中,但出现安装错误。
我的 NPM 安装是这样的:
ionic cordova plugin add cordova-sqlite-storage
npm install @ionic-native/sqlite
//ionic plugin add cordova-sqlite-storage ==> this one makes error
在 main.js 中,我尝试了以下各项:
import SQLite from 'ionic-native';
import {SQLite} from 'ionic-native';
import SQLite from '@ionic-native/sqlite';
import {SQLite} from '@ionic-native/sqlite';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
以下是错误:a) npm 警告,b) 控制台错误,以及 c) Chrome main.js 检查员
这是来自 main.js 的代码(最后一行是一切都失败的地方)。
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App },
render : (h) => h(App),
mounted() {
this.storage = new SQLite();
*** 我将此问题标记为已回答,但似乎还没有答案。我会继续努力的。
@ionic/vue 仍处于测试阶段,团队 working on integrating it with the Vue CLI. They are also using Capacitor, not Cordova, as the official native bridge for this project. As such it is recommended to use Capacitor if at all possible. Should you go that route, their storage API 可以代替 SQLite。
如果您想继续使用 Cordova 项目,Ionic Storage 抽象将不可用,因此您将不得不完全绕过 Ionic。
使用 Cordova CLI 安装 plugin(不需要 @ionic-native/sqlite
):
cordova plugin add cordova-sqlite-storage
直接使用插件,例如
const db = window.sqlitePlugin.openDatabase({...})
db.executeSql('INSERT...', [...values], callbackFn, errorFn)