【发布时间】:2020-01-17 02:06:13
【问题描述】:
我在 Laravel 项目的视图中添加了一些 Vue 代码。我是否需要在布局中包含 vuejs,例如:
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.12/vue.js"></script>
或者 laravel 会以某种方式处理它。
我尝试过的:
我运行了npm install 和npm run dev,现在我在公共目录中有app.js 和app.css。
我在视图中有以下内容:
const app = new Vue({
el: '#app',
data: {
comments: {},
post: {!! $post->toJson() !!},
user: {!! Auth::check() ? Auth::user()->toJson() : 'null' !!},
comment: 'Your Comment'
},
mounted(){
this.getComments();
},
methods:{
getComments(){
//Some code here
}
}
});
但是当我访问这个视图时,我得到:
ReferenceError: Vue is not defined
【问题讨论】:
标签: laravel-vue