简体   繁体   中英

How can I create and configure multiple Vue Instance in Laravel Mix?

I have a PHP project with Laravel and Vue.js I want to handle Admin and Client separately. So I need to add 1 Vue Instance. But I don't know how to create and configure it. Please help me to solve this problem. Thank you very much.

mix
  .js('resources/js/admin.js', 'public/js').vue()
  .js('resources/js/client.js', 'public/js').vue()

On your blade file, inject proper js file like:

@if (str_contains(Route::currentRouteName(), "admin"))
<script src="{{ asset('js/admin.js') }}" defer></script>
@else
<script src="{{ asset('js/clients.js') }}" defer></script>
mix.js('resources/front/js/app.js', 'public/js').vue()
.sass('resources/front/css/app.scss', 'public/css')
    .options({
    autoprefixer: {
        options: {
            browsers: [
                'last 6 versions',
            ]
        }
    }
})
mix.browserSync('your_site')


mix.js('resources/admin/js/adminapp.js', 'public/js').vue()
.sass('resources/admin/css/adminapp.scss', 'public/css')
.options({
    autoprefixer: {
        options: {
            browsers: [
                'last 6 versions',
            ]
        }
    }
})
mix.browserSync('your_site/admin')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM