fix: Script Setup Does Not Populate Name Property
#10348:
- Adding clarification on how to access
nameproperty in script setup
Description of Problem
In script setup, the name property does not get created, per here.
Proposed Solution
In order to help clarify what can be used, it makes sense to add a reference to __name to help devs that need access to the component's name in script setup.
Additional Information
Original PR that introduced __name
Deploy Preview for vuejs ready!
| Name | Link |
|---|---|
| Latest commit | 01094c3e3d03c63a371dc1541632d9f4e882daa9 |
| Latest deploy log | https://app.netlify.com/sites/vuejs/deploys/65d3916ae370800008ef896a |
| Deploy Preview | https://deploy-preview-2703--vuejs.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
I don't think this should be added because the inference is an internal mechanism. Can you clarify your use case here?
I don't think this should be added because the inference is an internal mechanism. Can you clarify your use case here?
Absolutely! I use script setup, and I need to be able to reference the name of the component programmatically... according to the docs, I should be able to use name, but I can't because script setup sets __name, and it wasn't clear which property to use. I would rather not have to go through each component and use defineOptions({ name: "ComponentName" }); if the name is inferred from the file (which is what I want).
I use script setup, and I need to be able to reference the name of the component programmatically...
What are you doing with the name?
What are you doing with the name?
For display purposes, retrieving it for an include/exclude list in KeepAlive, and other use cases that apply for the Options API.