Ad

ReferenceError: Vue Is Not Defined (laravel)

- 1 answer

I know there have lots of similar questions of this but I couldn't find a solution from those.

Already installed npm of vue and successfully compiled using npm run dev, I don't know why it return this kind of error below.

ReferenceError: Vue is not defined

This is my setup in my app.js:

import Vue from 'vue';
import VueRouter from 'vue-router';

window.Vue = Vue;
Vue.use(VueRouter);

new Vue({
    el: '#app',
    router
});

In my welcome.blade.php

<html>
    <head>
        <meta name="csrf-token" content="{{ csrf_token() }}">
        <link target="_blank" rel="nofollow noreferrer" href="{{ mix('css/app.css') }}" rel="stylesheet">
    </head>

    <body>
        <div id="app">
            <button class="btn btn-primary">Sample</button>
        </div>

        <script src="{{ mix('js/manifest.js') }}"></script>
        <script src="{{ mix('js/vendor.js') }}"></script>
        <script src="{{ mix('js/app.js') }}"></script>
    </body>
</html>

Someone knows where I went wrong?

Ad

Answer

I'm curious on what's inside your bootstrap.js. Maybe can you show us, might you import something that is using Vue, on which apparently fail to import.

Ad
source: stackoverflow.com
Ad