[Vuejs]-Dynamic post entry

0👍

If you want this.movies to be updated when the user clicks "previous" or "next" you’ll have to call the fetchMovies method in the onPrevBtnClick and onNextBtnClick methods. Currently onPrevBtnClick and onNextBtnClick only update this.currentPage, but doing so will not automatically cause fetchMovies to execute if fetchMovies is a method.

An alternative approach would be to make this.movies a computed property that is based on this.currentPage and get rid of fetchMovies, putting that logic in the computed property.

Check out the guide on Computed Properties and Watchers for more information. The key things to understand are:

  1. "computed properties are cached based on their reactive dependencies. A computed property will only re-evaluate when some of its reactive dependencies have changed."
  2. Methods never reevaluate on their own like computed properties. Methods need you to explicitly call them.

Leave a comment