Vue.js unknown custom element

前端 未结 9 2006
我在风中等你
我在风中等你 2020-12-02 11:01

I\'m a beginner with Vue.js and I\'m trying to create an app that caters my daily tasks and I ran into Vue Components. So below is what I\'ve tried but unfortunately, it giv

相关标签:
9条回答
  • 2020-12-02 11:39

    I had the same error

    [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

    however, I totally forgot to run npm install && npm run dev to compiling the js files.

    maybe this helps newbies like me.

    0 讨论(0)
  • 2020-12-02 11:40

    Don't overuse Vue.component(), it registers components globally. You can create file, name it MyTask.vue, export there Vue object https://vuejs.org/v2/guide/single-file-components.html and then import in your main file, and don't forget to register it:

    new Vue({
    ...
    components: { myTask }
    ...
    })
    
    0 讨论(0)
  • 2020-12-02 11:42

    OK, this error may seem obvious, but one day I was looking for an answer JUST TO FOUND OUT THAT I HAD 2 times COMPONENTS declared. it was driving me nuts as VueJS does not complain at all when you declare it 2 times, obvious I had a lot of code in between, and when I added a new component, I placed the declaration in the top, while I also had one close to the bottom. So next time looks for this first, saves a lot of time

    0 讨论(0)
提交回复
热议问题