Created
May 2, 2019 01:56
-
-
Save papalardo/a398132b9ab00201cd4849b06d5cbf48 to your computer and use it in GitHub Desktop.
Realtime clock VueJS
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
<template> | |
<div class="callout calendar-day"> | |
<div class="grid-x align-middle align-middle"> | |
<div class="shrink cell"> | |
<h1>{{ this.momentInstance.format('DD') }}</h1> | |
</div> | |
<div class="auto cell"> | |
<h6>{{ this.momentInstance.format('[de] MMMM [de] YYYY') }}</h6> | |
<h6 class="light">{{ this.momentInstance.format('dddd[.] HH:mm:ss') }} </h6> | |
</div> | |
</div> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
momentInstance: moment() | |
} | |
}, | |
mounted() { | |
setInterval(() => { | |
this.momentInstance = moment() | |
}, 1000) | |
} | |
} | |
</script> | |
<style> | |
.callout.calendar-day { padding: .8rem 1.9rem; } | |
.callout.calendar-day h1 { | |
margin: 0 1rem 0 0; | |
color: #2540F4; | |
} | |
.callout.calendar-day h6 { margin: 0; } | |
.callout.calendar-day h6.light { color: #A8B4CB; } | |
</style> |
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
import Vue from 'vue' | |
import App from './App.vue' | |
import moment from './plugins/moment' | |
Vue.use(moment) | |
Vue.config.productionTip = false | |
new Vue({ | |
store, | |
router, | |
render: h => h(App) | |
}).$mount('#app') |
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
import moment from 'moment' | |
import 'moment/locale/pt-br' | |
const install = function(Vue, options) { | |
window.moment = moment | |
window.moment().locale('pt-br') | |
Vue.prototype.moment = window.moment | |
} | |
export default { install } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment