Skip to content

Latest commit

 

History

History
122 lines (92 loc) · 4.85 KB

README.md

File metadata and controls

122 lines (92 loc) · 4.85 KB

@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

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  // ...
  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

Composition API

<script lang="ts" setup>
const dayjs = useDayjs()
dayjs().format('YYYY/MM/DD')

// Or

const { $dayjs } = useNuxtApp()
$dayjs().format('YYYY/MM/DD')
</script>

Options API

<script lang="ts">
import Vue from 'vue'

export default Vue.extend({
  data() {
    return {
      latestClicked: null
    }
  },
  methods: {
    handleClickButton() {
      this.latestClicked = this.$dayjs().format('YYYY/MM/DD')
    }
  }
})
</script>

Development

  • Run npm run dev:prepare to generate type stubs.
  • Use npm run dev to start playground in development mode.

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!