I am rendering html using v-html in which I am binding to a click event like so:
<template>
<q-page fill-height>
<div>
<q-btn flat @click="drawer = !drawer" round dense icon="menu" />
<span v-html="html"></span>
</div>
</q-page>
</template>
<script>
...
data: {
return {
id: null
}
},
mounted() {
this.$el.children[0].children[1].addEventListener("click", function(event) {
event.preventDefault();
console.log(event.target.id)
});
}
</script>
This prints event.target.id to the console as expected. It seems that the value of event.target.id can not be set to a reactive property.
How can I set the value of event.target.id equal to a different reactive data property so I can handle changes properly?
event.target.id? Also, you shouldn't need to add a native click handler here.@click.prevent="handleClick($event)"would work too (wherehandleClickis a custom method)