为什么我找不for循环,我尝试使用下面的一些代码,总是会出问题 #474
Unanswered
zhengcailu17
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
在【脚本编写】里面,我需要将相应的结果(json对象)重复读取出来,交给使用者去选择,可是我没有找到预先设定的相关功能,if倒是有的,我该怎么去处理这些数据,使它可以被重复读取。
第一次错误
var R = JSON.parse(response.body);
var list = setVariable("list", R.result.list);
var choices = [];
for (var i = 0; i < list.length; i++) {
choices.push(list[i].number);
}; 执行的时候提示这里出错了。
var userChoiceIndex = await showChooseDialog("请选择一个项", choices);
var selectedItem = list[userChoiceIndex];
selectedItem
第二次尝试
list.forEach(function(item) {
choices.push(item.number);
}); 提示错误
第三次尝试
var choices = list.map(function(item) {
return item.number;
}); 提示错误
下面是需要处理的数据
[{
"id": 563,
"type": 2,
"typeName": "海",
"number": "11-22-33-44-55-66",
"workArea": "S7",
"workContent": "文件",
"startTime": "2025-02-12 09:59:24",
"endTime": "2025-02-12 16:30:36"
}, {
"id": 565,
"type": 2,
"typeName": "东",
"number": "2-33-44-55-66-77",
"workArea": "S2",
"workContent": "编辑",
"startTime": "2025-02-11 10:50:00",
"endTime": "2025-02-11 16:30:49"
}, {
"id": 563,
"type": 2,
"typeName": "青",
"number": "33-44-55-66-77-88",
"workArea": "S6",
"workContent": "插件",
"startTime": "2025-01-21 09:02:00",
"endTime": "2025-01-21 17:00:00"
}
]
app版本 3.25.0
Beta Was this translation helpful? Give feedback.
All reactions