0

Hi I have an axios which it returns to an array like this one:

My axios code:

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;
                })

The response:

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,…]

How you can see it is a multidimensional 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>

I wonder how can I list like above? I tried everything and I can not be able to do it

Thanks!

1 Answer 1

1

Do you want to have a table with three columns that are full_name, rut, and an input with total rows equal to response.full_name.length or response.rut.length or response.total_days.length?

If so you can try this:

<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>

Please let me know if this is what you really ask or not

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.