Options API:
<script>
import { defineComponent } from 'vue'
export default defineComponent({
name: 'CustomName', //
inheritAttrs: false, //
setup() {
return {}
},
})
</script>
How to do that in <script setup>
, is there an equivalent for name
and inheritAttrs
like defineProps
and defineEmits
?
<script setup>
// how to define them here?
</script>
With Vue ^3.3, you can now use
defineOptions()
directly:The
<script setup>
syntax provides the ability to express equivalent functionality of most existing Options API options except for a few:name
inheritAttrs
If you need to declare these options, there're two ways:
defineOptions()
, this might be the most succinct approach:<script>
block withexport default
:Compiled output: