VueJS mustache undefined constant VueJS mustache undefined constant laravel laravel

VueJS mustache undefined constant


If you are using a .blade.php file then you need to do:

<div id="tuto">  <p>@{{ texte }}</p></div>

That's because blade also uses mustaches, so they get processed by blade before vue even sees them, which is why you are receiving an error from Laravel and not from Vue.

See the Blade & JavaScript Frameworks section of the Laravel docs for more details.


There are two ways going about that.

1: Use the @ before the mustaches.

Example:

@{{ texte }}


2: The other one is to use the @verbatim directive over a code block.

Example:

@verbatim    {{ texte }}@endverbatim

https://laravel.com/docs/5.4/blade#blade-and-javascript-frameworks


data must be a function:

var vm = new Vue({    el: '#tuto',    data: function(){        return {            texte: '<span>Mon texte</span>'        }    }});