[Vuejs]-How to set background-color with vue-router

0👍

You could watch the route in the component you wish to change the background color and insert the business logic there.

To create watchers you can do so by:

watch: {
$route.path: function (val) {
  this.backgroundColor = whateverYouWant
},
}

If you want this behavior to be used in other components too you can also create a mixin with this watcher.

Leave a comment