我在ionic2中编码,我使用Sqlite,但我收到此错误"无法打开数据库cordova_not_available"。如何解决这个问题
感谢帮助。
我的错误(无法打开数据库cordova_not_available(
我的代码;
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
import { TabsPage } from '../pages/tabs/tabs';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = TabsPage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
statusBar.styleDefault();
splashScreen.hide();
let db = new SQLite();
db.create({
name: "iothook.db",
location: "default"
}).then((db1:SQLiteObject) => {
db1.executeSql("CREATE TABLE IF NOT EXISTS kullanici (id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, password TEXT , token TEXT , user_id INTEGER)", {}).then((data) => {
console.log("TABLE CREATED: ", data);
}, (error) => {
console.error("Unable to execute sql", error);
})
}, (error) => {
console.error("Unable to open database", error);
});
});
}
}
Cordova功能仅在移动设备上可用。它们在浏览器中不受支持。