我的錯誤:獲取錯誤ionic3項目中'SQLite'類型不存在屬性'openDatabase'?
Runtime Error Uncaught (in promise): TypeError: _this.sqlstorage.openDatabase is not a function TypeError: _this.sqlstorage.openDatabase is not a function at http://localhost:8100/build/main.js:67:30 at t.invoke (http://localhost:8100/build/polyfills.js:3:9283) at Object.onInvoke (http://localhost:8100/build/vendor.js:4508:37) at t.invoke (http://localhost:8100/build/polyfills.js:3:9223) at r.run (http://localhost:8100/build/polyfills.js:3:4452) at http://localhost:8100/build/polyfills.js:3:14076 at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9967) at Object.onInvokeTask (http://localhost:8100/build/vendor.js:4499:37) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9888) at r.runTask (http://localhost:8100/build/polyfills.js:3:5143)
堆棧
Error: Uncaught (in promise): TypeError: _this.sqlstorage.openDatabase is not a function TypeError: _this.sqlstorage.openDatabase is not a function at http://localhost:8100/build/main.js:67:30 at t.invoke (http://localhost:8100/build/polyfills.js:3:9283) at Object.onInvoke (http://localhost:8100/build/vendor.js:4508:37) at t.invoke (http://localhost:8100/build/polyfills.js:3:9223) at r.run (http://localhost:8100/build/polyfills.js:3:4452) at http://localhost:8100/build/polyfills.js:3:14076 at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9967) at Object.onInvokeTask (http://localhost:8100/build/vendor.js:4499:37) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9888) at r.runTask (http://localhost:8100/build/polyfills.js:3:5143) at c (http://localhost:8100/build/polyfills.js:3:13535) at http://localhost:8100/build/polyfills.js:3:14107 at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9967) at Object.onInvokeTask (http://localhost:8100/build/vendor.js:4499:37) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:9888) at r.runTask (http://localhost:8100/build/polyfills.js:3:5143) at o (http://localhost:8100/build/polyfills.js:3:2203) at HTMLDocument.invoke (http://localhost:8100/build/polyfills.js:3:10985)
我Home.ts文件:
import { Component } from '@angular/core';
import { NavController,Platform } from 'ionic-angular';
import {SQLite} from "@ionic-native/sqlite";
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
sqlstorage: SQLite;
items: Array<Object>;
constructor(public navCtrl: NavController, private platform: Platform) {
this.platform.ready().then(() => {
for (var i = 100000 - 1; i >= 0; i--) {
console.log("test");
}
this.sqlstorage = new SQLite();
this.sqlstorage.openDatabase({name: "items.db", location: "default"}).then(() => {
this.createTables();
this.findAll();
}, (err) => {
console.log("!!! ", err);
});
});
}
public createTables(){
this.sqlstorage.executeSql(`create table if not exists items(
reference CHAR(10) PRIMARY KEY,
name CHAR(30),
qMin FLOAT,
qReal FLOAT
))`, {});
}}
離子版本的詳細信息
離子框架:3.6.0
個離子應用程序腳本:2.1.3
方芯:4.1.3
角度編譯CLI:4.1.3
節點:8.2.1
OS平臺:Linux 4.4
導航器平臺:Linux x86_64
用戶代理:Mozilla/5.0(X11; Linux的x86_64的)爲AppleWebKit/537.36(KHTML,例如Gecko)Chrome瀏覽器/ Safari瀏覽器60.0.3112.78/537.36
我想:
npm install --save @ionic-native/sqlite
但並沒有幫助。
您是否找到了解決方案? – robbannn