HarmonyOS List提示undefined
类中定义了一个chooseIds字段列表属性,调用clear方法却提示undefined,代码如下:
import { List } from '@kit.ArkTS';
export class HealthEvaluationBean {
id: number = -1; //题目ID
qmId: number = -1; //试卷ID
title: string = '';
type: number = -1; //选择类型 1单选 2多选
needChoice: number = -1; //是否必须选择 0否 1是
backgroundImg: string = ''; //背景图
chooseIds: List<number> = new List<number>(); //记录底下列表的选择项,以此来判断单选的
systemQuestionDetailOptionVoList: SystemQuestionDetailOptionVoListBean[] = []; //答案选项列表
}
//直接代码中调用(不管chooseIds中有没有数据,都调用clear)
this.preData.chooseIds.clear()
//报错 TypeError: Cannot read property clear of undefined
HarmonyOS
赞
收藏 0
回答 1
待解决
相关问题
HarmonyOS 手势注册是否能够在build()方法外写,在方法外写会提示undefined
1392浏览 • 1回复 待解决
List滚动到底部提示,是否有好的解决方案?
2769浏览 • 1回复 待解决
HarmonyOS Object is possibly 'undefined'. <ArkTSCheck>报错
1776浏览 • 1回复 待解决
HarmonyOS Cannot read property setMissionContinueState of undefined
1329浏览 • 1回复 待解决
HarmonyOS UIAbilityContext.openLink 为 undefined
1104浏览 • 1回复 待解决
HarmonyOS创建前置广角相机返回undefined
1059浏览 • 1回复 待解决
HarmonyOS SourceTool.xxx值为undefined
1203浏览 • 1回复 待解决
使用fetch报错,fetch undefined
8563浏览 • 2回复 待解决
HarmonyOS List嵌套List和List嵌套Grid问题
1333浏览 • 1回复 待解决
HarmonyOS Cannot set property when setter is undefined
1285浏览 • 1回复 待解决
HarmonyOS CustomDialog中的CustomDialogController 为undefined
1589浏览 • 1回复 待解决
HarmonyOS代码报错 cannot read property aboutToRender of undefined
1806浏览 • 1回复 待解决
HarmonyOS CustomDialogController一直是undefined
1469浏览 • 1回复 待解决
建前置广角相机返回undefined
507浏览 • 0回复 待解决
如何获取单例为undefined
1637浏览 • 1回复 待解决
HarmonyOS error: undefined symbol: OH_ImageNative_GetImageSize
726浏览 • 1回复 待解决
HarmonyOS List嵌套list中的布局
1238浏览 • 1回复 待解决
HarmonyOS list嵌套list,scrollToItemInGroup不执行
1076浏览 • 1回复 待解决
HarmonyOS 代码提示功能弹不出提示了
1057浏览 • 1回复 待解决
HarmonyOS 4.0 hdc使用hdc list targets 报empty,hdc install提示[Fail]ExecuteCommand need connect-key?
10199浏览 • 1回复 待解决
HarmonyOS 调试报错TypeError:Cannot read property xxx of undefined
3786浏览 • 1回复 待解决
HarmonyOS NEXT开发中遇到UIAbilityContext.openLink 为 undefined
455浏览 • 0回复 待解决
HarmonyOS 读取剪贴板api获取内容为undefined
1273浏览 • 1回复 待解决





















参考示例如下:
需要实例化JSON.parse()并不会实例化对象。