Laravel undefined variable exception with vue.js

前端 未结 2 389
醉话见心
醉话见心 2021-01-13 09:04

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

{{message}}

相关标签:
2条回答
  • 2021-01-13 09:09

    add @{{message}}

    that will tell blade to ignore this.

    0 讨论(0)
  • 2021-01-13 09:18

    It's not a good approach to combine the same notation for front-end and back-end. Of course, with the @, Blade can ignore.

    A much cleaner idea is to extract the front-end from back-end, because Blade and Vue.js use the same notation:

    • Front-end with html, css en javascript (in your case Vue.js)
    • Back-end (in php, Laravel in your case) as REST-api with php that returns json

    The big advantages:

    • It's more secure
    • It's more maintainable
    • It's cleaner
    0 讨论(0)
提交回复
热议问题