我尝试编写一个基本的 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/