0๐
โ
I hope I understood you correctly, but this is probably some boilerplate of what you want:
Vue.directive('demo', function (el, binding) {
// Add any event listener here that you want
el.addEventListener('touchstart', () => {
// Execute the function bound to the directive
binding.value()
})
})
const app = new Vue({
el: '#app',
})
And the template:
<div id="app">
<h1 v-demo="() => {alert('hello')}">Click me for alert</h1>
</div>
Or in your case:
<custom-element v-demo="() => {this.$emit('change', 'test', true)}" />
๐คPhilip Feldmann
Source:stackexchange.com