0

working with Laravel 5.7 and Vue Js. this is app.js

let Myheader = require('./components/Myheader.vue');
let Myfooter = require('./components/Myfooter.vue');

const app = new Vue({
    el: '#app',
    components:{Myheader,Myfooter}
});

blade.php file

<body>
<div id="app">
<Myheader></Myheader>
<Myfooter></Myfooter>
</div>
<script src="{{ asset('js/app.js')}}"></script>  
</body>

but when I run artisan serve command it is not displayed vue component. how can fix this problem?

3
  • 6
    You can't build Vue files with artisan serve. Try npm run watch or npm run dev. Be sure, you have npm installed. By the way, check your console output, should ne some errors there :) Commented May 2, 2019 at 13:19
  • yes, I have run npm run watch as well but error is here Commented May 2, 2019 at 15:24
  • and console output is this [Vue warn]: Failed to mount component: template or render function not defined. found in ---> <Myfooter> <Root> Commented May 2, 2019 at 15:34

1 Answer 1

1

If you are use Laravel Mix 4.0+, try adding .default to your requires. This is needed when you use CommonJS to import modules.

let Myheader = require('./components/Myheader.vue').default; 
let Myfooter = require('./components/Myfooter.vue').default;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.