defineSlots
Stability:
stableDeclaring type of SFC slots in <script setup> using the defineSlots.
For Vue >= 3.3, this feature will be turned off by default.
| Features | Supported |
|---|---|
| Vue 3 | ✅ |
| Nuxt 3 | ✅ |
| Vue 2 | ✅ |
| Volar Plugin + Vue 3 | ✅ |
| Volar Plugin + Vue 2 | ❌ (Volar does not support it yet) |
Basic Usage
vue
<script setup lang="ts">
defineSlots<{
// slot name
title: {
// scoped slot
foo: 'bar' | boolean
}
}>()
</script>Volar Configuration
jsonc
// tsconfig.json
{
"vueCompilerOptions": {
"target": 3, // or 2.7 is not supported by Volar.
"plugins": [
"@vue-macros/volar/define-slots"
// ...more feature
]
}
}