Laravel Vue.js的未定义变量异常 [英] Laravel undefined variable exception with vue.js

查看:219
本文介绍了Laravel Vue.js的未定义变量异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在laravel刀片系统中测试一个简单的vue.js,这是我在test.blade.php视图文件中的代码:

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>

问题是,渲染视图文件laravel希望以变量或常量的形式访问消息,并且由于没有传递任何 message 变量以查看时,我得到了使用未定义的常量异常.那有什么解决方案呢?

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?

推荐答案

添加@ {{message}}

add @{{message}}

这将告诉Blade忽略它.

that will tell blade to ignore this.

这篇关于Laravel Vue.js的未定义变量异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆