我无法在Laravel 5.4上测试简单的vue示例组件 [英] I can't test simple vue example component on Laravel 5.4
问题描述
我重新安装了laravel 5.4,运行npm install
,然后继续测试示例vue组件,但是什么也没发生.
I have a fresh laravel 5.4 installation, i run npm install
and then proceed to test the example vue component, but nothing happens.
在我的项目目录中,运行npm run dev
,它可以正常编译.然后我执行php artisan serve
,我看到的只是一个空白页.
On my project's directory I run npm run dev
and It compiles just fine. Then I execute php artisan serve
and all I see is a blank page.
这是我的观点,这是我编写的唯一代码:
Here's my view, which is the only code I wrote:
<html>
<head>
<title>Laravel</title>
</head>
<body>
<div id="app">
<example></example>
</div>
<script src="/js/app.js"></script>
</body>
</html>
可以吗?我错过了什么吗?
Is that ok? am I missing something?
在我的package.json上,在devDepentencies上,以及其他我拥有的东西:"vue": "^2.1.10"
On my package.json, on devDepentencies, among other stuff I have: "vue": "^2.1.10"
推荐答案
这是因为您没有运行php artisan make:auth
,所以laravel并未将JavaScript对象"Laravel"设置为"csrfToken"属性.
It is because you didn't run php artisan make:auth
so laravel didn't set the javascript object "Laravel" with "csrfToken" property.
在resources/assets/js/bootstrap.js中,尝试注释此行:
In resources/assets/js/bootstrap.js, try to comment this line :
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;
并使用npm run dev
重新编译.
这篇关于我无法在Laravel 5.4上测试简单的vue示例组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!