javascript - 在vue js中随机播放对象的对象
问题描述
我想随机排列测验的每个问题的答案
[{"answers 1":"9 s 58","answer2":"9 s 72","answer3":"8 s 42","answer4":"8 s 36"},{"answer1":"Ottawa","answer2":"Toronto","answer3":"Montréal","answer4":"Québec"},{"answer1":"Mathilde","answer2":"Elizabeth","answer3":"Fabiola","answer4":"Paola"}]
import shuffle from 'lodash/shuffle';
export default {
mounted() {
this.$axios
.get("http://localhost:4000/api/answers/" + this.$route.params.idQuiz)
.then((response) => {
this.reponses = response.data;
for (var question in this.reponses){
shuffle(this.reponses[question])
}
console.log(this.reponses);
})
.catch((error) => {
console.log(error);
}),
解决方案
推荐阅读
- maven - 如何在 POM 的本地磁盘中添加指向 JAR 的插件?
- mysql - 选择 distinct 在 mysql 上花费大量时间
- java - 找不到文件错误Google Drive API:Springboot
- vue.js - 如何在 vue 中设置用户创建的子域?
- nosql - DynamoDbEnhancedClient.BatchWriteItem(Dynamo DB 版本 2)和 DynamoDBMapper.BatchSave(版本 1)之间的区别
- python - 将 JSON 文件转换为表格格式
- c++ - 如果模板参数具有特定运算符,则启用函数
- python - 带有 pytest 的 sklearn 导致致命的 Python 错误:分段错误
- java - ElasticSearch - 内部 lucene 文件删除永远挂起
- android - 如何在 Android Pie 中禁用深色主题?(Android 10 之前)