I can't test simple vue example component on Laravel 5.4

对着背影说爱祢 提交于 2019-12-11 10:14:42

问题


I have a fresh laravel 5.4 installation, i run npm install and then proceed to test the example vue component, but nothing happens.

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?

On my package.json, on devDepentencies, among other stuff I have: "vue": "^2.1.10"


回答1:


It is because you didn't run php artisan make:auth so laravel didn't set the javascript object "Laravel" with "csrfToken" property.

In resources/assets/js/bootstrap.js, try to comment this line :

window.axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;

And recompile with npm run dev.



来源:https://stackoverflow.com/questions/43407709/i-cant-test-simple-vue-example-component-on-laravel-5-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!