I can't test simple vue example component on L

2019-07-29 09:23发布

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条回答
We Are One
2楼-- · 2019-07-29 10:08

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.

查看更多
登录 后发表回答