1
2

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 3 years have passed since last update.

Vuetify Vue 確認ダイアログ

Posted at

作りたいもの

「開く」ボタンをクリックすると以下のようなダイアログを出す。
「閉じる」ボタンでダイアログを消し、
確認ボタンを押すとメソッドを実行する。

スクリーンショット 2021-05-16 21.08.25.png

サンプル

my_dialogを初期はfalseにしておき、
「開く」ボタンをクリックすると、@click="my_dialog = true"でtrueになりダイアログを出す。

.vue
<template>
  <v-app>
    <v-btn @click="my_dialog = true">開く</v-btn>
    <v-dialog v-model="my_dialog" max-width="400">
      <v-card>
        <v-card-title>
          <div>タイトル</div>
        </v-card-title>
        <v-card-text>
          <p>本文</p>
        </v-card-text>

        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn @click="my_dialog = false">閉じる</v-btn>
          <v-btn @click="confirm">確認</v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
  </v-app>
</template>
<script>
export default {
  data() {
    return {
      my_dialog: false,
    }
  },
  methods: {
    confirm() {
      alert('確認しました')
      this.my_dialog = false
    },
  },
}
</script>
1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?