Subscribe on changes!

How to get component `$options` via composition API?

avatar
Mar 25th 2023

What problem does this feature solve?

With Options API, we can access the component options via this.$options, but with Composition API I don't see any documentation mentions about this?

What does the proposed API look like?

n/a

avatar
Mar 25th 2023

There's no public API for this. what's your use case?

avatar
Mar 25th 2023
<script setup>
import { getCurrentInstance } from 'vue'

const i = getCurrentInstance()
console.log(i.proxy.$options)
</script>

Warning: It's not a public API, and could be changed anytime. Use at your risk.

avatar
Mar 25th 2023

@LinusBorg I want to get the component name and the component path for a custom composable. I found that the $options contains __name and __file property.