【问题标题】:Vue.js - Single file component - Unknown custom elementVue.js - 单个文件组件 - 未知的自定义元素
【发布时间】:2020-12-03 10:12:02
【问题描述】:

我有一个简单的单文件组件,名为“MobileApps.vue”:

<template>
    <div class="grey-bg about-page">
        <p>{{ greetings }}</p>
    </div>
</template>

<script>
    export default {
        name: 'Home',
        data() {
            return {
                greetings: "Hello"
            }
        }
    };
</script>

并注册它:

const app = new Vue({
el: '#app',
router,
components: {
    Home,
    About,
    Gas,
    Electricity,
    Contacts,
    Electricity_info,
    Gas_info,
    MobileApps
},
data: {
},
created() {
},
destroyed() {

},
mounted() {
    let mySVGsToInject = document.querySelectorAll('img.inject-me');
    SVGInjector(mySVGsToInject);
},
methods: {
}

});

当我尝试使用 &lt;MobileApps&gt; 组件打开 HTML 文件时,我会收到错误消息:

vue.esm.js:628 [Vue 警告]:未知的自定义元素:- 您是否正确注册了组件?对于递归组件,请确保提供“名称”选项。

但即使我提供了一个名字,也没有任何反应。

【问题讨论】:

  • 这能回答你的问题吗? Vue component name must be lowercase?
  • @underscore_d nope.
  • 很奇怪,因为据我所知,您接受的答案表明您有相同的根本原因。
  • @underscore_d 对不起,我的错。你的权利。

标签: javascript html vue.js vuejs2 vue-component


【解决方案1】:

尝试使用 cabeb-case 格式 &lt;mobile-apps&gt; 喜欢:

 <mobile-apps></mobile-apps> 

【讨论】:

    猜你喜欢
    • 2018-12-23
    • 1970-01-01
    • 2018-05-29
    • 2019-08-11
    • 2017-04-28
    • 2021-03-07
    • 2017-08-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多