JSFiddle - React, Tailwind, and code Playground
by mbudnik
HTML
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<div id="app">
<button v-on:click="increase(2, $event)">
Click me!
</button>
<p>
{{ counter }}
</p>
<p v-on:mousemove="updateCoordinates">Coordinates: {{ x }} / {{ y }} - <span v-on:mousemove="dummy">DEAD SPOT</span>
</p>
</div>
JavaScript
new Vue({
el: '#app',
data: {
counter: 0,
x: 0,
y: 0
},
methods: {
// access to event object
increase: function(step, event) {
this.counter += step;
},
updateCoordinates: function(event) {
this.x = event.clientX;
this.y = event.clientY;
},
dummy: function(event){
event.stopPropagation();
}
}
})