我有一個 Ionic Angular 應用程式(Android 版本)
我有以下幾點:
getAllUsers() {
return this.dbInstance.executeSql(`SELECT * from ${this.db_table}`)
.then((data) => {
if (data.rows.length > 0) {
for (let i = 0; i < data.rows.length; i ) {
console.log('hello world');
console.log(JSON.stringify(data.rows.item(i)));
}
}
}).catch(e => {
console.log(JSON.stringify(e));
});
}
當我呼叫 getAllUsers 時,會在 android studio 中使用以下控制臺日志自動拋出例外
2021-12-30 17:50:32.831 25077-25077/io.ionic.starter I/Capacitor/Console: File: http://localhost/src_app_login_login_module_ts.js - Line 421 - Msg: {"rows":{"length":3},"rowsAffected":0}
這是來自控制臺的查詢日志:
2021-12-30 17:50:32.815 25077-25292/io.ionic.starter V/Capacitor/Plugin: To native (Cordova plugin): callbackId: SQLitePlugin1622878251, service: SQLitePlugin, action: backgroundExecuteSqlBatch, actionArgs: [{"dbargs":{"dbname":"userParameters.db"},"executes":[{"sql":"SELECT 1","params":[]},{"sql":"SELECT * from userParametersTable","params":[]}]}]
我想知道為什么會發生這種行為以及如何解決這個問題。
謝謝
uj5u.com熱心網友回復:
問題是我需要包含引數(以前是可選的,如下所示:
return this.dbInstance.executeSql(`SELECT * from ${this.db_table}`, [])
代替
return this.dbInstance.executeSql(`SELECT * from ${this.db_table}`)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/400353.html
上一篇:錯誤TS2362:算術運算的左側必須是“any”、“number”、“bigint”型別(在字串插值{{}}內)
