With Vue ^3.3, you can now use defineOptions()
directly:
<script setup>
defineOptions({
name: 'CustomName',
inheritAttrs: false,
customOptions: {},
})
</script>
The <script setup>
syntax provides the ability to express equivalent functionality of most existing Options API options except for a few:
name
inheritAttrs
- Custom options needed by plugins or libraries
If you need to declare these options, there're two ways:
- If using Vue Macros, you can use
defineOptions()
, this might be the most succinct approach:
<script setup>
defineOptions({
name: 'CustomName',
inheritAttrs: false,
customOptions: {},
})
</script>
- If you don't want to rely on external libraries, you can use a separate normal
<script>
block with export default
:
<script>
export default {
name: 'CustomName',
inheritAttrs: false,
customOptions: {},
}
</script>
<script setup>
// script setup logic
</script>
Compiled output:
<script>
export default {
name: 'CustomName',
inheritAttrs: false,
customOptions: {},
setup() {
// script setup logic
},
}
</script>