If I have a reusable component called Modal
in my application and I want to dynamically bind functions to the Yes
button, how can I pass a function to the @click
event of the Yes
button within the Modal
as a prop? For example:
//data tags are used for fast markup here only
<template>
<div>
<div :id="`${id}`" data-modal>
<div data-modal-title>
{{title}}
</div>
<div data-modal-body>
{{body}}
</div>
<div data-modal-footer>
<button @click="//event to be passed//" data-modal-button-ok>Yes</button>
<button data-modal-button-cancel>Yes</button>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'modal',
props: [
'id',
'title',
'body',
// event?
]
}
</script>
When using this modal, how should the event be passed?
<Modal id="x" title="y" body="z" //event="????"//></Modal>