Demian
Demian

Reputation: 115

"Failed to mount component: template or render function not defined" in simple component

I'm trying to start from basics in vuejs+webpack development.

I created a demo project here: https://github.com/Demian87/vue-test

It builds fine, but after launch I recieve an error from titile to console and my component in index changes to

<!--function (a, b, c, d) { return createElement(vm, a, b, c, d, true); }-->

I'm using package.json from demo project for vuejs+webpack. I took webpack.config from there also, but I still get that error and nothing works.

Any ideas about the error reason?

Upvotes: 0

Views: 553

Answers (1)

Sui Dream
Sui Dream

Reputation: 550

I noticed that your component lacks name:

export default {
    name: 'hello',
    data: function() {
        return {
            greeting: 'Привет всем!'
        }
    }
}

I rewrote main.js as

import Vue from 'vue';
import Hello from '../components/hello.vue';

new Vue({
    el: '#app',
    components: {
        hello : Hello
    }
})

Also, there is a typo in template: {{ greetings }} instead of {{ greeting }}.

Upvotes: 1

Related Questions