【问题标题】:[Vue warn]: Unknown custom element[Vue 警告]:未知的自定义元素
【发布时间】:2018-02-06 08:34:32
【问题描述】:

我是 vuejs 新手,在 laravel 框架中编写一个 js 代码时,出现错误:

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

App.js

import Vue from 'vue'
import Vcinfo from './Vcinfo.vue'
import router from './router'

const app = new Vue({
    el: '#vcinfo',
    components: { Vcinfo },
    template: '<app></app>',
    router
})

请建议怎么做?

【问题讨论】:

  • 您的模板包含&lt;app&gt;&lt;/app&gt;,但您没有导入名为app 的组件。

标签: javascript laravel vue.js vuejs2 vue-router


【解决方案1】:

这是给未来的读者的。 我犯了一个错误,我不得不像这样使用它。

import Vue from 'vue'
import Vcinfo from './Vcinfo.vue'
import router from './router'

const app = new Vue({
    el: '#vcinfo',
    components: { Vcinfo },
    template: '<vcinfo></vcinfo>',
    router
})

根据此导入import Vcinfo from './Vcinfo.vue'

【讨论】:

    猜你喜欢
    • 2017-12-22
    • 2020-03-28
    • 2019-12-14
    • 2018-01-08
    • 2019-09-22
    • 2019-07-07
    • 2021-01-01
    • 2018-04-08
    • 2018-09-14
    相关资源
    最近更新 更多