Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save balazimichal/18d6b4ddd6d6bda8c2a38d2ba22c48db to your computer and use it in GitHub Desktop.
Save balazimichal/18d6b4ddd6d6bda8c2a38d2ba22c48db to your computer and use it in GitHub Desktop.
vue-simple-counter
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Vue</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<h1>{{ counter }}</h1>
<button v-on:click="increase(2)">+</button><button v-on:click="decrease(2)">-</button>
</div>
<script>
new Vue({
el: '#app',
data: {
counter: 0
},
methods: {
decrease: function(step) {
this.counter = this.counter - step
},
increase: function (step) {
this.counter = this.counter + step
}
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment