Skip to content

Use the parent directory name as the component name #7156

Description

@yuri-li

What problem does this feature solve?

componentName("/order/Index.vue")="Order"

What does the proposed API look like?

  1. 检查所有用到正则/([^/\\]+)\.\w+$/的代码
  2. (正确)获取componentName的部分代码
const match = Component.__file.match(/([/\\](\w+))?([/\\](\w+))\.\w+$/)
if (match) {
    if (capitalize(match[4]) === "Index") {
        const dirName = match[2]
        name = capitalize(dirName)
    } else {
        name = match[4]
    }
}

Activity

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

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