Skip to content

Instantly share code, notes, and snippets.

Created January 16, 2017 11:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2876ad575724b562733933f80fe78951 to your computer and use it in GitHub Desktop.
Save anonymous/2876ad575724b562733933f80fe78951 to your computer and use it in GitHub Desktop.
Counter // source https://jsbin.com/xogokodara
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Counter</title>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div id="app" class="container text-center">
<p style="font-size: 60px"> {{ votes }} </p>
<button @click="count" class="btn btn-primary">Count</button>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
<script id="jsbin-javascript">
new Vue({
el: '#app',
data: {
votes: 0
},
methods: {
count() {
var that = this;
setInterval(function() {
if (that.votes < 20) {
that.votes++
}
}, 500)
}
}
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">new Vue({
el: '#app',
data: {
votes: 0
},
methods: {
count() {
var that = this;
setInterval(function() {
if (that.votes < 20) {
that.votes++
}
}, 500)
}
}
});</script></body>
</html>
new Vue({
el: '#app',
data: {
votes: 0
},
methods: {
count() {
var that = this;
setInterval(function() {
if (that.votes < 20) {
that.votes++
}
}, 500)
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment