Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel undefined variable exception with vue.js

I want to test a simple vue.js in laravel blade system, Here is my code in test.blade.php view file:

<div id="app">
   <p>{{message}}</p>
</div>
 <script src="{{url('/assets/js/vue/vue.min.js')}}"></script>
 <script>
  new Vue({
    el:'#app',
    data:{
        message:"hello world"
    }
});
</script>

The problem is while rendering view file laravel wants to access the message as a variable or constant and because there is no any message variable passed to view I get Use of undefined constant exception. So what's the solution?

like image 545
Tohid Dadashnezhad Avatar asked Jan 28 '16 19:01

Tohid Dadashnezhad


1 Answers

add @{{message}}

that will tell blade to ignore this.

like image 55
Sari Yono Avatar answered Oct 31 '22 14:10

Sari Yono