jericopulvera's avatar

Vue.js and laravel blade?

I'm learning Vue.js in my laravel 5.2 folder and I noticed that wherever I refresh the page it shows the data name first before outputting the actual data. I suspect that it is because of blade @ within {{ }} do you think this is the problem? or not?

This is the code I used.



    <div id="app">
        <h1> @{{ message }} </h1>
    </div>


<script src={{ asset('js/vendor.js') }}></script>

<script> 
new Vue ({
    el: '#app',
    data: {
     message: 'hellow world' 
    }
});
</script>

what is the solution to this problem? I need your help guys T_T

0 likes
4 replies
Shovels's avatar

To clarify for anyone (like me) stumbling across this: You need to add the following to your CSS...

[v-cloak] {
    display: none;
}

Then on all Vue elements/components in your html/blade files...

// from
<div class="someclass" v-model="example"></div>

// to
<div v-cloak class="someclass" v-model="example"></div>

The element will initially have 'display:none' applied, then when Vue renders it will remove the attribute causing it to show on the page

1 like

Please or to participate in this conversation.