javascript - Laravel Blade 上的 Vuejs

标签 javascript laravel vue.js laravel-blade

我尝试编写一个基本的 vue 脚本,但它在我的 larave Blade 模板中不起作用。

我收到此错误:

app.js:32753 [Vue warn]: Property or method "message" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

(found in )

到目前为止的代码:

@extends('layouts.app')

@section('content')

    <div id="foo">
      @{{ message }}
    </div>

@endsection

@section('javascript')
    <script>
    new Vue({
      el: '#foo',
      data: {
        message: 'Hello Vue!'
      }
    })
    </script>
@endsection

最佳答案

看不出有什么问题。所以问题可能出在这段代码

@section('javascript')
    <script>
    new Vue({
      el: '#foo',
      data: {
        message: 'Hello Vue!'
      }
    })
    </script>
@endsection

您的 layouts/app.blade.php 中可能没有 yield('javascript')

关于javascript - Laravel Blade 上的 Vuejs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46847035/

相关文章:

Javascript - 单击一个元素以将其内容复制到剪贴板

javascript - 带有条件字段的 PHP 表单

php - 如何在 Laravel 中将 count(*) 设置为字段名称

Laravel 可终止中间件和后中间件之间的区别

vue.js - Vuex "context"对象是什么?

javascript - Vue将元素数据绑定(bind)到html属性

javascript - 访问 $.each() 中的项目

javascript - Firebase orderByValue().equalTo() 不是一个函数(Node JS)

php - Laravel:无法在 Blade 中使用 Carbon diffForHumans

javascript - Vuejs 3(组合 API)v-model 渲染 [对象对象]