0

I am working on a project in .NET with MVC and Vue.js, at the moment of wanting to use the components I have to declare it as follows:

import Vue from 'vue';

import example from './components/example.vue'
import equiposcrear from './components/equipos/crear.vue'
import equipos from './components/equipos/index.vue'
import cargardiesel from './components/equipos/cargarDiesel.vue'

const app = new Vue({
    el: '#app',
    components: {
        example,
        equiposcrear,
        equipos,
        cargardiesel
    }
})

If i registered as Vue.component('equipos', require('./components/equipos/index.vue'));

At the moment i want to use send the error that the component is not registered

@{
    ViewBag.Title = "Equipos";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div id="app">
    <equipos></equipos>
</div>

What am i doing wrong?

German Ortiz
  • 619
  • 1
  • 5
  • 8

1 Answers1

0

A local component registration like you are doing has two parts. You need to specify the tag-name, then the source. Like this...

components: {
    'example': example,
    'equiposcrear' : equiposcrear,
    'equipos' : equipos,
    'cargardiesel' : cargardiesel
}
    

Here's the doc.

tony19
  • 125,647
  • 18
  • 229
  • 307
bbsimonbb
  • 27,056
  • 15
  • 80
  • 110
  • 2
    OP is using ES6, so it doesn't really matter if the object key has the same name as the imported variable. – yuriy636 Aug 23 '17 at 20:10
  • yes, if i use import example from './components/example.vue' and load the component as works well, but with Vue.component('example', require('./components/example.vue')); send the error component not register – German Ortiz Aug 23 '17 at 20:27