@nuxtjs/dayjs
The best way for use Day.js easily in your Nuxt.js project.
404,248
| Install | |
|---|---|
npm install @nuxtjs/dayjs |
|
| Latest Version: | 1.4.1 |
| License: | MIT |
| Last Updated: | Oct 7, 2021 |
| Links: | npm |
@nuxtjs/dayjs
The best way for use Day.js easily in your Nuxt.js project.
Installation
$ yarn add @nuxtjs/dayjs # or npm install
Usage
1. Register dayjs module to your Nuxt Application
export default {
// ...
modules: [
'@nuxtjs/dayjs'
],
// Optional
dayjs: {
locales: ['en', 'ja'],
defaultLocale: 'en',
defaultTimeZone: 'Asia/Tokyo',
plugins: [
'utc', // import 'dayjs/plugin/utc'
'timezone' // import 'dayjs/plugin/timezone'
] // Your Day.js plugin
}
// ...
}
2. Use $dayjs on Context, Vue instance
with Context
<script>
export default {
asyncData({ $dayjs }) {
return {
now: $dayjs().format('YYYY/MM/DD')
}
}
}
</script>
with Vue instance
<script>
export default {
data() {
return {
latestClicked: null
}
},
methods: {
handleClickButton() {
this.latestClicked = this.$dayjs().format('YYYY/MM/DD')
}
}
}
</script>
For Typescript users
Add the types to your "types" array in tsconfig.json after the @nuxt/types entry.
For dayjs plugins, add their relative types like dayjs/plugin/_pluginName_.
tsconfig.json
{
"compilerOptions": {
"types": [
"@nuxt/types",
"@nuxtjs/dayjs",
"dayjs/plugin/relativeTime",
]
}
}
Development
$ git clone https://github.com/nuxt-community/dayjs-module.git
$ cd @nuxtjs/dayjs
$ yarn
License
MIT @potato4d
Note
This project generated by create-nuxt-module
Contributors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
Related Packages
@geins/ralph-module-voyado-elevate
Component library for Voyado Elevate integrations with Ralph Storefront
3,784
Version History
| Version | Released | License |
|---|---|---|
| 1.4.1 | MIT | |
| 1.4.0 | MIT | |
| 1.3.1 | MIT | |
| 1.3.0 | MIT | |
| 1.2.1 | MIT | |
| 1.2.0 | MIT | |
| 1.1.12 | MIT | |
| 1.1.11 | MIT | |
| 1.1.10 | MIT | |
| 1.1.9 | MIT | |
| 1.1.8 | MIT | |
| 1.1.7 | MIT | |
| 1.1.6 | MIT | |
| 1.1.5 | MIT | |
| 1.1.4 | MIT | |
| 1.1.3 | MIT | |
| 1.1.2 | MIT | |
| 0.0.0 |