Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template>
- <span>{{ timer }}</span>
- </template>
- <script>
- data () {
- return {
- now: '',
- }
- },
- created () {
- this.getServerTime ();
- },
- computed: {
- timer () {
- return moment (this.now).format ('YYYY/MM/DD HH:mm:ss');
- }
- },
- methods: {
- getServerTime () {
- let $vmc = this;
- Axios.get ([API])
- .then (resp => {
- $vmc.now = resp;
- setInterval (() => $vmc.now += 1000, 1000);
- })
- }
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement