I want to access the "name" variable from <script> in my <script setup> block. I cant seem to figure out how to do it. I have tried importing options from '*.vue' but that prompts me to install module '*.vue'.
<script>
export default {
name: 'some name'
}
</script>
<script setup>
//use the 'name' variable here
</script>
name
property? It defines the display name of the component, and otherwise is only used for self-reference in the template. There should be no reason to need it in a component's code. – Stanchionname
is forced to be filename in script setup. If generated name is acceptable, you can use getCurrentInstance().proxy.$options.name , but it's not reliable – PilatusgetCurrentInstance().proxy.$options.name
and get that name. Try it and tell us what happens :) – Stanchion<script> import NAME_CONSTANT from 'someFile' export default { name: NAME_CONSTANT } </script> <script setup> //use NAME_CONSTANT here </script>
– Hafiz