docs icon indicating copy to clipboard operation
docs copied to clipboard

fix: Script Setup Does Not Populate Name Property

Open incutonez opened this issue 1 year ago • 5 comments

#10348:

  • Adding clarification on how to access name property 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

incutonez avatar Feb 19 '24 17:02 incutonez

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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Feb 19 '24 17:02 netlify[bot]

I don't think this should be added because the inference is an internal mechanism. Can you clarify your use case here?

yyx990803 avatar Mar 13 '24 02:03 yyx990803

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).

incutonez avatar Mar 13 '24 03:03 incutonez

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?

flogehring avatar Jul 10 '24 21:07 flogehring

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.

incutonez avatar Jul 11 '24 03:07 incutonez