4

i have this on vue template:

<div v-for="item in items" :key="item.id">
  <!-- content -->
</div>

i want get the value of item.id and send via axios.

i dont know how bind de value from template to script section.

1 Answer 1

5

You can put a button with a on click handler inside the div:

<div v-for="item in items" :key="item.id">
  <button @click="sendItem(item.id)">Send</button>
</div>

And define the handler in methods section:

<script>
export default {
data: ...
methods: {
    sendItem: function(itemId) {
        // Using axios here
    }
}
}
</script>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.