let pointResults = data.data.pointResults //data 为后端传过来的值
//历遍数组
for (let i in pointResults) {
submit_mark += pointResults[i].judgePointScore
submit_taketime = pointResults[i].runTime
submit_memory = pointResults[i].runMemory
}
以上方法为最基础的用for循环套出来的,若后端拿到的变量名与js中写法一致,只需要直接复制即可,比如:
后端传过来的值变量名为judgePointScore ,而前端变量名也叫judgePointScore直接
judgePointScore = data.data.pointResults.judgePointScore
不需要再循环复制
我们有时还可以用forEach或者every,some等等
forEach无返回值,但every有