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?

【Vue3】名前付きスロットの使い方

Posted at

コード

App.vue
<template>
  <CardTemplate>
    <template #body>
      <!-- 表示させたいパーツを書く -->
      <span>中身</span>
    </template>
    <template #footer>
      <span>フッター</span>
    </template>
  </CardTemplate>
</template>

<script setup>
import CardTemplate from 'CardTemplate.vue'
</script>
CardTemplate.vue
<template>
  <v-card>
    <v-card-title>タイトル</v-card-title>
    <v-card-text>
      <slot name="body"></slot>
    </v-card-text>
    <v-card-actions>
      <slot name="footer"></slot>
    </v-card-actions>
  </v-card>
</template>

スロット名は任意。今回はbodyfooterにした。

参考

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?