Closed totsteps closed 5 years ago
@gagan0723 Have you save the page number in url or anywhere else? For your scenario, I think the page number should be get from the url after refresh.
eg. /posts/3
for the third page. After refresh, you can still get the page number from the url. You can set the number to the component.
@lokyoung thanks for the reply.
I think the page number should be get from the url after refresh.
I tried that before but it didn't work out. Doing so does get the actual response from the backend(for example /posts/3
gets the data for page 3) but the page jumps back to the first page and an additional request is made to the backend for the first page.
@gagan0723 After the refresh, you can get the page number from the router. And you should send the page number to the pagination component by v-model
. And you should fetch the third page by yourself.
I am having a hard time figuring out how to stay on the same page after a page refresh.
Let's say I have 4 pages for the
/posts
route. When I browse the/posts
route the first time it fetches the first page. Now I click on page 3 and it fetches the 3rd page. Now I refresh the browser and it should again fetch the 3rd page, but instead, it fetches the first page and the first page gets active on the pagination component!!Is there a way to tell the component to pass the selected page number to the
click-handler
even after the browser window is refreshed?Here's how I am using the component:
Handler:
Thanks.