0

I have a Laravel + VueJS application and I am having trouble with the following issue:

  • What method would I use to return the Vue Page. Return View doesnt work which is what I expected but I am unaware what I put there.

Here's my code:

routes/web.php-

Route::get('/pizzas', function () {
    return view('Pizzas');
});

the Vue file directory is resources/js/Pages/Pizzas.vue

1
  • Vue is using one-page concept. Not work like that. Use API json request-response and init page what load vuejs. Commented Nov 14, 2020 at 4:43

1 Answer 1

1

You can try to add your component to app.js(Im assuming you already have this in your resources folder) with:

window.Vue = require('vue');
Vue.component('pizza-component', require('./Pages/Pizzas.vue').default);
const app = new Vue({
    el: '#app',
});

And in your laravel blade, use the component like this:

<div id="app">
    <pizza-component></pizza-component>
</div>

This works for me when trying to use a Vue compnent in a blade template file

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.