Struggling with Vue.js while learning on the fly. I've created a page that lists articles and paginated it. However, when clicking on an article on page two and then trying to go back or return to the list, the page number doesn't save. How do I ensure it remembers the correct page even after leaving the page? Appreciate any help!
const routes = [
{
name: 'news',
path: '/:currentPage',
component: vueApp
}
]
const router = new VueRouter({
routes
})
var vueApp = new Vue({
router,
el: '#news-wrapper',
data: function data() {
return {
filteredArticles: [],
timer: null,
currentPage: 1,
perPage: 10,
pages: [],
articles: [ array ]
}
},
updated: function updated() {
var page = this.currentPage;
this.$router.replace({ name: 'news', params: {currentPage: this.currentPage}})
}
Need assistance in ensuring the page number is saved when navigating back to the list. Should I create a new value for this purpose?
Please let me know if you require more of my code!