标题: 代码报错Property 'rdbStore' has no initializer and is not definitely assigned in the constructor. <ArkTSCheck> [打印本页] 作者: ershi 时间: 2024-10-10 15:37 标题: 代码报错Property 'rdbStore' has no initializer and is not definitely assigned in the constructor. <ArkTSCheck> 【求大佬解决】
```
class DBUtil{
//使用变量来获取关系型数据库操作对象
rdbStore: relationalStore.RdbStore
if(result.rowCount <= 0) { //如果行数<=0表示没查询到
return arr //直接返回空数组
}
//循环处理结果,循环条件:当所在行不是最后一行
while (!result.isAtFirstRow) {
//如果不是最后一行,去往下一行
result.goToLastRow()
//解析数据,转换对象
let obj:GeneratedObjectLiteralInterface_2= {}
columns.forEach(info => {
let val: number | string | Uint8Array | null
switch (info.type) {
case ColumnType.LONG:
val = result.getLong(result.getColumnIndex(info.columName))
break;
case ColumnType.DOUBLE:
val = result.getDouble(result.getColumnIndex(info.columName))
break;
case ColumnType.STRING:
val = result.getString(result.getColumnIndex(info.columName))
break;
case ColumnType.BLOB:
val = result.getBlob(result.getColumnIndex(info.columName))
break;
}
Object(obj)[info.name] = val
})
//复制完成将对象填入结果数组
arr.push() //arr.push(obj)
Logger.debug('查询到的数据:' + JSON.stringify(obj))
}
return arr
}
//转换表中列的数据类型
buildValueBucket(obj: RecordPO, columns: ColumnInfo[]): relationalStore.ValuesBucket {
let value:ValuesBucket = {}
columns.forEach(info => {
let val: ValuesBucket = Object(obj)[info.name] //获取列名
if (typeof val !== 'undefined') { //判断val不是没找到
Object (value)[info.columName] = val //如果名字不是undefined将名字复制给value
}
})
return value
}
}
let dbUtil: DBUtil = new DBUtil()
export default dbUtil as DBUtil
```
在网上找的方法是在rdbStore: relationalStore.RdbStore下面创建一个构建函数,但是创建完let dbUtil: DBUtil = new DBUtil()这里需要传一个参数我不清楚要传什么参数,有没有大佬可以帮忙看看这个问题要怎么解决
使用的是api10
DevEvoStudio版本:5.0
SDK版本: 作者: hyacinth养花人 时间: 2024-10-11 09:19 标题: 代码报错Property 'rdbStore' has no initializer and is not definitely assigned in the constructor. <ArkTSCheck> [md]成员变量rdbStore初始化一定要赋值,可以这么写: