2

I am creating a node_module with Vue SFC components for consumption of different projects.

So on my module's index.js (main entry point), I have this:

import component1 from './src/input-box1.vue'
import component2 from './src/input-box2.vue'

export default component1

Above works well for component1 but I don't know how to export component2.

I tried doing this:

export { component1 }
export { component2 }

But I'm getting an error:

Unknown custom element: <component1> - did you register the component correctly? For recursive components, make sure to provide the "name" option

Import is like this:

import component1 from 'sample-vue-components'

Any ideas??

1
  • export default { component1, component2, ... } or export component1; export component2; .. Commented Jan 19, 2021 at 9:24

1 Answer 1

6

If you don't put {} it is the default export that will be imported. Try modifying your export/import like:

in your sample-vue-components.vue:

import component1 from './src/input-box1.vue'
import component2 from './src/input-box2.vue'

export { component1, component2 };

Then import them like:

import { component1, component2 } from 'sample-vue-components'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.