Created
February 3, 2018 15:54
-
-
Save Siemko/b9da853c586190281f956cd06de1cd16 to your computer and use it in GitHub Desktop.
Counter component in Vue.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<section class="section"> | |
<div class="container"> | |
<h2 class="title">{{title}}</h2> | |
<div class="level"> | |
<div class="level-item"> | |
<button class="button" @click="incrementCounter"> | |
<span class="icon"> | |
<i class="fa fa-plus"></i> | |
</span> | |
</button> | |
</div> | |
<div class="level-item"> | |
<h2>{{counter}}</h2> | |
</div> | |
<div class="level-item"> | |
<button class="button" @click="decrementCounter"> | |
<span class="icon"> | |
<i class="fa fa-minus"></i> | |
</span> | |
</button> | |
</div> | |
</div> | |
</div> | |
</section> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
title: "Counter", | |
counter: 0 | |
}; | |
}, | |
methods: { | |
incrementCounter() { | |
this.counter++; | |
}, | |
decrementCounter() { | |
this.counter--; | |
} | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment