Skip to content

Add inferred component name(__name) to <script> #6357

Open
@zhuscat

Description

@zhuscat

What problem does this feature solve?

compiler-sfc adds __name property to <script setup>, but it does not adds __name property to regular <script>. Is it appropriate to add __name to all types of <script> so I can get inferred name if one component does not have a name property.

What does the proposed API look like?

In all conditions, I can get __name:

export default {
  mounted() {
    console.log(this.$options.__name)
  }
}
<script setup>
const inst = getCurrentInstance().proxy
onMounted(() => {
  console.log(inst.$options.name)
})
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions