Creation of Global Vue component

Asked

Viewed 26 times

-1

Good afternoon..

I’m having the following error when trying to create a global component with VUEJS..

main.js

import Vue from 'vue'
import App from './App.vue'
import vuetify from './plugins/vuetify';
import Menu from '@/components/template/Menu';

Vue.config.productionTip = false
Vue.component = ('app-menu', Menu)

new Vue({
  vuetify,
  render: h => h(App)
}).$mount('#app')

App.Vue

<template>
  <v-app>

    <app-menu></app-menu>

    <Toolbar />

    <v-content>
      <Carousel />
    </v-content>

    <Footer />
  </v-app>
</template>

<script>
import Toolbar from "@/components/template/Toolbar";
import Carousel from "@/components/widgets/Carousel";
import Footer from "@/components/template/Footer";

export default {
  components: {Toolbar, Carousel, Footer },
};
</script>

ERROR:

[Vue warn]: Unknown custom element: - Did you Register the Component correctly? For recursive Components, make sure to provide the "name" option.

found in

---> at src/App.Vue

  • 2

    Vue.Component = ('app-menu', Menu) switch to Vue.Component('app-menu', Menu) to think that this syntax is incorrect

  • Thank you very much, that was really the problem.

  • Blz, I’ll answer the question

  • Only read the documentation: https://br.vuejs.org/v2/guide/components-registration.html

1 answer

1

Your syntax of the method Vue.component is incorrect, the correct syntax is Vue.component('app-menu', Menu)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.