Skip to content

fix: Script Setup Does Not Populate Name Property#2703

Open
incutonez wants to merge 1 commit into
vuejs:mainfrom
incutonez:10348
Open

fix: Script Setup Does Not Populate Name Property#2703
incutonez wants to merge 1 commit into
vuejs:mainfrom
incutonez:10348

Conversation

@incutonez

@incutonez incutonez commented Feb 19, 2024

Copy link
Copy Markdown

#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

- Adding clarification on how to access `name` property in script setup
@netlify

netlify Bot commented Feb 19, 2024

Copy link
Copy Markdown

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit 01094c3
🔍 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.

@yyx990803

Copy link
Copy Markdown
Member

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

@incutonez

incutonez commented Mar 13, 2024

Copy link
Copy Markdown
Author

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

@flogehring

Copy link
Copy Markdown
Contributor

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?

@incutonez

Copy link
Copy Markdown
Author

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.

@bencodezen bencodezen requested a review from yyx990803 August 30, 2024 16:37
@bencodezen bencodezen added the state: awaiting-feedback Needs more input before further actions can be taken label Aug 30, 2024
@lakkvak

lakkvak commented Dec 22, 2025

Copy link
Copy Markdown

I have the same problem. Is there a solution?

@softboy99

softboy99 commented May 25, 2026

Copy link
Copy Markdown

I have the same problem. Is there a solution? how about dynamic name relation with route.name? we still use vite-plugin-vue-setup-extend-plus. But which cannot deal with dynamic route related name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: awaiting-feedback Needs more input before further actions can be taken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants