Skip to content

Instantly share code, notes, and snippets.

@Shipu
Created December 19, 2017 17:00
Show Gist options
  • Save Shipu/108f486f2e1326cac121dfbbe5f39962 to your computer and use it in GitHub Desktop.
Save Shipu/108f486f2e1326cac121dfbbe5f39962 to your computer and use it in GitHub Desktop.
Counter Example in Vue.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Vue Timer</title>
</head>
<body>
<div id="app">
{{ time }}
</div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
var app = new Vue({
el: '#app',
data: {
time: 5
},
mounted() {
interval = setInterval(() => {
if(this.time == 0) {
return;
}
this.time = this.time-1;
}, 1000)
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment