I\'m using Vue router with two pages:
let routes = [
{
path: \'/\',
component: require(\'./components/HomeView.vue\')
},
{
pa
I ran into an issue when I wanted to modify the styles of the html
and body
tags along with the #app
container on specific routes and what I found out is that for various reasons, this can be quite complicated.
After reading through:
In your App.vue (could be considered as the centralised state):
So for the route /
you get the red style and for all other routes the pink style is applied.
The handleStyles
logic could have been dealt with by the beforeCreated
hook however in my case, this would only affect the html
and body
styles but the #app
element where the router view is rendered into would only available when the dom has been mounted so I think that it is a slightly more extensible solution.