【发布时间】:2019-03-25 20:15:56
【问题描述】:
我从一个 API 中提取数据,该 API 为我提供了一个项目对象,每个项目都包含一个名为 correct_answer 的字符串和一个名为 incorrect_answers 的数组。
我试图在每个项目中合并这些值,所以当我执行v-for 时,它会循环遍历合并在一个循环中的答案。我还想随机化这些答案的顺序。
对象外观示例:
"results": [
{
"question": "Where was the Games of the XXII Olympiad held?",
"correct_answer": "Moscow",
"incorrect_answers": [
"Barcelona",
"Tokyo",
"Los Angeles"
]
},
{
"question": "What is the first weapon you acquire in Half-Life?",
"correct_answer": "A crowbar",
"incorrect_answers": [
"A pistol",
"The H.E.V suit",
"Your fists"
]
},
]
【问题讨论】:
标签: javascript arrays vue.js vuejs2