Skip to content

feature proposal: make <component :is='xx' work #643

@lishaobos

Description

@lishaobos

Clear and concise description of the problem

<component :is='xx' is not work.

Suggested solution

user can provide some comments:

/* unplugin-vue-components ['name1', 'name2'] */

or we can provide API like this:

defineUnpluginComponents(
    ['name1', 'name2']
)

and then we auto imported name1,name2

before

(_openBlock(), _createBlock(_resolveDynamicComponent("name1")))

after

import name1 from 'xx'
import name2 from 'xx'

const _getUnpluginDynamicComponent = name => {
  const _unpluginDynamicComponent = {
      name1,
      name2
  }

  return _unpluginDynamicComponent[name] || name
}


// we can replace the _resolveDynamicComponent
(_openBlock(), _createBlock(_resolveDynamicComponent(_getUnpluginDynamicComponent("name1"))))


// or we can inject components
defineCompoennt({
  components: { name1, name2  },
  setup() {
  // ...
  }
})

Alternative

No response

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate### Clear and concise

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions