0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

nuxt.jsの日付フォームで初期値を今日とする

Posted at

nuxtでformを作成する時

nuxt.js
<input type=“date”/>

としますが
この初期値を
今日の日付にしたい

そんな時の記述です。

ちなみにデフォルトだと
yyyy/mm/dd
になります。

結論

Screen Shot 2022-08-25 at 17.44.17.png

nuxt.js
<template>
  <div>
    <input
      v-model="date"
      type="date"
    />
    <input
      type="date"
    />
  </div>
</template>

<script>
export default {
  data () {
    return {
      date: new Date().toISOString().substring(0, 10)
    }
  }
}
</script>

これでいけます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?