如何使用vejs从这个多维数组创建一个列表?



嗨,我有一个axios它返回到一个像这样的数组:

我的axios代码:

axios.post('/api/hr_employee/days/'+ this.period_data.year +'/'+ this.period_data.month +'?page='+this.currentPage+'&api_token='+App.apiToken)
.then(response => {
this.posts = response.data.data;
console.log(this.posts);
this.rowsQuantity = 1000;
})

反应:

full_name: ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",…], rut: ["06152617-K", "06628494-8", "06802969-4", "06974036-7", "07066149-7", "07174172-9", "07274753-4",…], total_days: [30, 30, 30, 21, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 27, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,…]

如何看到它是一个多维的full_name, rut, days.

<tr v-for="(row, idx1) in posts">
<td>{{ row.full_name }}</td>
<td>{{ row.rut }}</td>
<td>
<input type="number" class="form-control" id="exampleInputEmail1" v-model="row.days" placeholder="">
</td>
</tr>

我想知道我怎么能像上面那样列出?我什么都试过了,就是不行

谢谢!

您是否希望有一个包含三列的表,分别是full_name、rut和一个输入,其总行等于response.full_name ?长度或response.rut.length或response.total_days.length?

如果是,你可以试试:

<tr v-for="(fullName, index) in posts.full_name"> // assuming full_name and rut and total_days have same length
<td>{{ fullName }}</td>
<td>{{ posts.rut[index] }}</td>
<td>
<input />
</td>
</tr>

请让我知道这是否是你真正想要的