[Vuejs]-Is there a way to keep the search results after leaving and coming back to a page?

1👍

You can store it in a so called client-side storage like LocalStorage before API call or when results are received and read it on page load for example. Read more about usage with vue.js here

Some example code to read a stored value from local storage: (this could be your search criteria)

const app = new Vue({
  el: '#app',
  data: {
    name: '',
    age: 0
  },
  mounted() {
    if (localStorage.name) {
      this.name = localStorage.name;
    }
    if (localStorage.age) {
      this.age = localStorage.age;
    }
  },
  methods: {
    persist() {
      localStorage.name = this.name;
      localStorage.age = this.age;
      console.log('now pretend I did more stuff...');
    }
  }
})

Leave a comment