Categories
Vue Answers

How to fix Vue.js unknown custom element error with JavaScript?

Spread the love

Sometimes, we want to fix Vue.js unknown custom element error with JavaScript.

In this article, we’ll look at how to fix Vue.js unknown custom element error with JavaScript.

How to fix Vue.js unknown custom element error with JavaScript?

To fix Vue.js unknown custom element error with JavaScript, we register our component before we use it.

To register it globally, we call Vue.component like

Vue.component("my-task", {
  // ...
});

new Vue({
  // ...
});

We create a register the my-task component with Vue.component.

To register a component locally, we write

export default {
  data() {
    return {};
  },
  components: {
    "my-task": MyTask,
  },
};

to register the my-task component in another component.

We set the my-task tag to render the MyTask component.

Conclusion

To fix Vue.js unknown custom element error with JavaScript, we register our component before we use it.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *