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:
- "computed properties are cached based on their reactive dependencies. A computed property will only re-evaluate when some of its reactive dependencies have changed."
- Methods never reevaluate on their own like computed properties. Methods need you to explicitly call them.
- [Vuejs]-Sometimes getting: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'
- [Vuejs]-Make file available in chrome from vue project in VS Code
Source:stackexchange.com