0

i want to bind selected rows to an array, i'm trying to bind data from a v-for to the value of my input. I tried v-bind:value="row.id", i tried value={{row.id}} but nothing seems to be working.

<tbody>
  <tr v-for="row in get_rows()">
    <td>
      <input type="checkbox" v-bind:value="row.id" v-model="selectedRows">
    </td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</tbody>

What am i doing wrong?

1

1 Answer 1

1

In order for your code to work you need to make sure you initialize selectedRows as an array. Add this to your component:

data() {
  return {
    selectedRows: []
  }
},
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.