1
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.

【Vuetify】v-expansion-panelとv-switchの併用

Last updated at Posted at 2022-11-27

やりたいこと

Google chromeの設定画面にあるような
スイッチトグルつきのアコーディオンを作りたい。
chorome.gif

コード例

<div id="app">
  <v-app id="inspire">
    <v-expansion-panels>
      <v-expansion-panel>
        <v-expansion-panel-header :hide-actions="true" :ripple="false" @click="openFlg = !openFlg">
          <template v-slot:default="{ open }">
            <v-row>
              <v-col cols="auto" class="mr-auto mt-3">テスト</v-col>
              <v-col cols="auto" class=" my-0 py-0">
                <v-switch :input-value="open"></v-switch>
              </v-col>
            </v-row>
          </template>
        </v-expansion-panel-header>
        <v-expansion-panel-content>
          テスト
        </v-expansion-panel-content>
      </v-expansion-panel>
    </v-expansion-panels>
  </v-app>
</div>
new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    openFlg: false,
  }),
})

実際の画面CodePen
https://codepen.io/shota-1314/pen/JjZvyXm

2022/11/28 追記
v-switchが非活性になっていたので修正

参考文献

1
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
1
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?