Vue js不断返回“未知的自定义元素”

时间:2018-11-07 08:00:11

标签: vue.js laravel-5.7

我确定我没有在代码中键入任何错误,因为我什至都没有更改它,但是我一直在控制台中不断收到Unknown custom element error,这是我的代码:

app.js     / **      *首先,我们将加载该项目的所有JavaScript依赖项      *包括Vue和其他库。这是一个很好的起点      *使用Vue和Laravel构建功能强大的强大Web应用程序。      * /

require('./bootstrap');

window.Vue = require('vue');

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */
Vue.component('example-component', require('./components/ExampleComponent.vue'));

const app = new Vue({
    el: "#app"
});

ExampleComponent.vue

<template>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card card-default">
                    <div class="card-header">Example Component</div>

                    <div class="card-body">
                        I'm an example component.
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        mounted() {
            console.log('Component mounted.')
        }
    }
</script>

enter image description here

1 个答案:

答案 0 :(得分:0)

Main File 
require('./bootstrap');

window.Vue = require('vue');

<template>
    <example-component></example-component>
</template>
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
Vue.component('example-component', require('./components/ExampleComponent.vue'));

const app = new Vue({
el: "#app"
});





<template>
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card card-default">
                <div class="card-header">Example Component</div>

                <div class="card-body">
                    I'm an example component.
                </div>
            </div>
        </div>
    </div>
</div>
</template>

<script>
export default {
    mounted() {
        console.log('Component mounted.')
    }
}
</script>