I can not connect the vuejs in Laravel

0

See page:

<!doctype html>
<html lang="{{ app()->getLocale() }}">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Laravel</title>

        <!-- Fonts -->
        <link href="css/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css">


    </head>
    <body>
        <div id="app">
            <h1>@{{ msg }}</h1>
        </div>


        <script src="js/vue/app.js"></script>
        <script src="js/vue/dist/vue.js" ></script>
        <script src="js/axios/dist/axios.js" ></script>

    </body>
</html>

These JavaScript files are in the public folder.

I was able to connect Bootstrap, but why could not I connect the JavaScript files?

    
asked by anonymous 12.10.2017 / 20:05

1 answer

1

Good morning! Laravel already has a VueJs implementation by default already configured to work, the easiest way to make it work is to use this implementation. If you check in Resources / Assets you will see the css, js, and sass subdirectories. Inside js you will see the component subdirectory with an example. To use this impementation you must type in the root directory of your npm install application, then LaravelMix will be installed. It looks a bit complicated, but it's well explained in Laravel's documentation on these links Frontend Sacaffolding and Compiling Assets that speaks in more detail. After npm install you can run npm run dev create a route to the resources / views / vue.blade.php file which is a sample VueJs file configured in Laravel. So all your code should be in resources / assets / js / component and always after some change you should run npm run dev to compile the code for the public / js / app.js file (this is the only file you should import to your HTML), all of this is done automatically by running npm run dev . I strongly suggest you use these features as they are tightly integrated with Blade and make programming much easier. Good luck!

    
16.10.2017 / 14:48