JSFiddle - React, Tailwind, and code Playground
by Breno RdV
HTML
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<div id="app">
<button v-on:click="inc">click me</button>
<button v-on:click="inc2(2)">click me2</button>
<button v-on:click="inc2(2, $event)">click me3</button>
<p>
{{ counter }}
</p>
<p v-on:mousemove="updtCoords">
Coordinates: {{ x }} / {{ y }} -
<span v-on:mousemove.stop="">DEAD SPOT</span>
</p>
<input type="text" v-on:keyup.enter.space="alertMe">
</div>
JavaScript
new Vue({
el: "#app",
data: {
counter: 0,
x: 0,
y: 0
},
methods: {
inc: function() {
this.counter++;
},
inc2: function(s) {
this.counter += s;
},
inc3: function(s, e) {
this.counter += s;
},
updtCoords: function(e) {
this.x = e.clientX;
this.y = e.clientY;
},
alertMe: function(e) {
alert('Alert!');
}
}
});