[Vuejs]-Vuetable return to page 1 after I have clicked page 5 and updated one of the content then click back

0👍

I have found the solution which is using local storage in vue.

In myvuetable.vue

onLoadingData (){
    if (window.location.href.indexOf("admin/sales_order") > -1) {
        if(Vue.localStorage.get('sales_order_admin_page')){
            this.$refs.vuetable.currentPage = Vue.localStorage.get('sales_order_admin_page');
        }
    }
}

In route.js

import VueLocalStorage from 'vue-localstorage'
Vue.use(VueLocalStorage)

Vue.use(VueLocalStorage, {
  name: 'ls',
  bind: true //created computed members from your variable declarations
})

Vue.localStorage.remove('sales_order_admin_page')

So when onload all the component I simply remove the local storage data first then whenever there is a page change then it will store the page in local storage. It will detect the url first then only update the page in vuetable. If the user didn’t click refresh then it won’t re-run all the component which means the route.js also won’t reload so the local storage data remain.

👤Max

Leave a comment