1.Not all code paths return a value
错误代码:
getTaskList() {
if (this.groupType === 'all') {
return this.tasks
}
else if (this.groupType === 'todo') {
return this.tasks.filter(item => item.state
{
if (item.state === false) {
return true
}
}
}
else if (this.groupType === 'finished') {
return this.tasks.filter(item => !item.state
{
if (item.state == true) {
return true
}
}
}
console.log('获取列表成功')
}
改为:
getTaskList() {
let task: Array<taskModel> = []
if (this.groupType === 'all') {
task = this.tasks
}
else if (this.groupType === 'todo') {
task = this.tasks.filter(item =>!item.state)
}
else if (this.groupType === 'finished') {
task = this.tasks.filter(item => item.state)
}
console.log('获取列表成功')
return task
}
原文链接:
ArkTs编译常见错误汇总(更新中)_indexed access is not supported for fields (arkts--CSDN博客
原文链接: