Created
December 19, 2017 17:00
-
-
Save Shipu/108f486f2e1326cac121dfbbe5f39962 to your computer and use it in GitHub Desktop.
Counter Example in Vue.js
This file contains 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
<!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