Refresh page conflicting between Windows and vuejs

Asked

Viewed 292 times

0

I’m studying the integration between Windows and vuejs, however, when I configure the routes through the Vue-router, when doing a refresh on the page, the Windows does not find the page or so, I need to go back to the index of the application to work all over again. Being more specific, let’s assume that I have a route that returns a json with some names, on the specific page, will be populated a list with vuejs, only that when giving a refresh on the page, the Aravel does not identify that the routing of vuejs and sends only the raw json, instead of returning the json to vuejs and then popular the page. I need to go back to the index of the application, click again on the link of the page I want to go to and then yes get the data through Vue. If I refresh the page it happens all over again, in short, every time the page is updated with F5, the Variable does not identify the vuejs routing. If the page does not return data, the Standard displays the typical page of not found, if there is data return, the raw data is shown, right on the page, without going through the vuejs. Does anyone know how to solve?

  • Could you post parts of your code and vuejs? Can I try to make an example of communication between Vue with Vue-Resource and Laravel, is that something that would help you? 'Cause the problem itself I can’t tell you how to fix without even seeing the code.

  • guastallaigor, is something to do with the mode: history of vuejs. I removed this from the application and now everything works correctly. However, I would not like to have this #.

1 answer

0


Felipe, I went through this same problem just now and treated as follows:

I left the web route(Routes/web.php) as follows:

Route::any('{all}', function () {
    return view('index');
})->where(['all' => '.*']);

So all routes will play to my view that calls Vue, and the calls to the api all went to the api route(Routes/api.php), in Vue the calls to the Laravel will all be in the /api

I’m starting with Vuejs this week so it might be wrong to work this way, but to me it seemed to make sense this way, because so I’m already leaving the API ready to be consumed by the front, and any web call the Laravel simply passes the responsibility of interpreting the route to the Vue.

In case I’m wrong in that thought, please someone correct me.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.