About the problem that vue route redirection cannot destroy the style

the problem starts along

Login page I design the background color for body, and then jump to the home page after a successful login. But the background color still exists.

my idea is to jump behind and take the initiative to destroy the corresponding dom and style.

is not done in vue.

although some friends on the network say, add scoped domain style control to style. But there is still no way to apply body html styles in this way.

I tried to add this restriction, but the style of this component was not destroyed after the route was redirected by vue.

imagine that if I cut a lot of components around, there aren"t many styles on the page.

I wonder if you have a good way to destroy the component style dom related to the vue route jump?


your approach is wrong, because when vue mounts dom, it mounts to-sharpapp.
the correct thing to do is to fill the body with a div given a div setting background element. In this way, each page has a different background color.


MVVM design requires you to change through data-driven dom
general new Vue, will not directly bind to the body tag, precisely because there will be the subject of the situation.
if you have many large components to switch, you need to add container,Vue instances in body to bind to container, and container contains large components. Background-color


direct DOM operation of large components is driven by data, document.getElementsByTagName ("body") [0] .style.background = "". Single-page applications basically rely on hierarchical masks to achieve

.
Menu