@nuxtjs/dayjs
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

@nuxtjs/dayjs

code style: prettier donate: Patreon License: MIT NPM version All Contributors NPM downloads codecov

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):


Takuma HANATANI(@potato4d)

💻 🐛 📖 💡 💬 👀

Bryan Daniel Velastegui Lucero

💻

Wei

💻

かずえもん

📖

Daiki Ojima

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.4.17,866latest

Version History

VersionDownloads (Last 7 Days)Published
1.4.17,866
1.4.0161
1.3.146
1.3.055
1.2.1151
1.2.041
1.1.120
1.1.110
1.1.100
1.1.913
1.1.80
1.1.71
1.1.60
1.1.50
1.1.40
1.1.30
1.1.20
0.0.01

Package Sidebar

Install

npm i @nuxtjs/dayjs

Weekly Downloads

8,335

Version

1.4.1

License

MIT

Unpacked Size

43.1 kB

Total Files

16

Last publish

Collaborators

  • clarkdo
  • pi0
  • atinux
  • alexchopin
  • danielroe
  • antfu
  • potato4d