Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[Vue warn]: Failed to generate render function:

Tags:

vue.js

I have this strange error which I cannot figure out.

I am using the latest VueJS, pulled from the official CDN with:

<script src="https://unpkg.com/vue/dist/vue.js"></script>

enter image description here

Specified line looks like below:

enter image description here

Did anyone experienced this? Is it a VueJS problem?

Later edit:

I believe the error is here:

    attrs: {
        "type": "text",
        "name": "phone",
        "value": "",
        "id": "phone",
        "phone_number":
    }

the v-bind on the "phone_number" field didn't work as expected for some reason.

Removed the :phone_number="phone_number" and wrote it again, and it just worked.

like image 492
Angelin Calu Avatar asked Mar 13 '17 17:03

Angelin Calu


1 Answers

If you are using Laravel and you are passing data in a Blade template like this:

<your-component :value="{{ $myValue }}"></your-component>

It may be that $myValue is null and therefore the error occurs.

A simple way to fix this is to use json_encode before passing values as an attribute to the component:

<your-component :value="{{ json_encode($myValue) }}"></your-component>
like image 186
Marvin Rabe Avatar answered Oct 24 '22 05:10

Marvin Rabe