D
D
demeys2018-10-17 10:31:06
Vue.js
demeys, 2018-10-17 10:31:06

How to solve the problem of Unknown custom element:?

Began to study vue
prescribed

Vue.component('example-component', require('./components/ExampleComponent.vue'));

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

HTML
<div id="app">
<example-component></example-component>
</div>

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>

in the console this error
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Pautov, 2018-10-17
@bootd

Where have you ever seen such a connection of components, as you have?

let ExampleComponent = require('./components/ExampleComponent.vue')

Vue.component(ExampleComponent.name, ExampleComponent);

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question