Skip to content
Advertisement

Unable to import/export vuejs components

I have a folder like this.

JavaScript

Classic and Modern are simple components with template, export default {} and a style. I am calling both inside index.js as:

JavaScript

So, when I import this module as:

JavaScript

I get this error

Unknown custom element: – did you register the component correctly? For recursive components, make sure to provide the “name” option.

I have name: "Classic" inside my components and I am including the in the current file using components: { Classic }, but I get the same error.

It only works if I export only one component as:

JavaScript

this will work and include the classic, but I can’t export both of them like seen in this example https://github.com/greyby/vue-spinner/blob/master/src/index.js

Advertisement

Answer

You need to use export for named exports, not export default:

JavaScript

See: https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement