Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

using the watch method to monitor route updates in vue

watch: {
  // Whenever the movie prop changes, fetch new data
  movie: {
    // Will fire as soon as the component is created
    immediate: true,
    handler(movie) {
      // Fetch data about the movie
      fetch(`/${movie}`).then((data) => {
        this.movieData = data;
      });
    }
  }
}
Source by michaelnthiessen.com #
 
PREVIOUS NEXT
Tagged: #watch #method #monitor #route #updates #vue
ADD COMMENT
Topic
Name
4+5 =