[RESOLVED] Router (Navigate) leaves Previous Page CSS Styles

I am suffering from an issue with v4. I am using ComponentURL to define my routes. Each component has its own custom “script tag” section. When I use router.navigate, it adds the custom “script tag” to the “head tag” (DOM) of the main page. However when I “navigate” to a 2nd page, it leaves the custom “script tag” from the 1st page in the “head tag” (DOM). If i navigate “navigate” to a 3rd page, it removes the “script tag” from the 1st page and leaves the “script tag” from the 2nd page in the DOM. How I am calling navigate

router.navigate({name : “profile”);

This continues and it always leaves the “script tag” section from the previous page. This is messing up my CSS greatly. Can anyone tell me if I am using navigate incorrect or is this a bug?

Вам нужно то, что в <script>, писать в data и methods - так задумано, а общий JS-код выносить из компонента.

I am doing as you said, however I am trying to override a common CSS in the SCRIPT tag in the component. I only need to override it in the 1 page. however since the previous page SCRIPT tag remains it messes up the styling of the next page that loads.I have tried “preloadPreviousPage : false” however that doesn’t have any effect. Is there anyway to stop it from keeping the previous page in the DOM?

Предыдущая страница нужна в DOM. Пример: вы открываете popup (как router component) на широком экране и он “всплывает” не на весь экран. В этом случае “предыдущая страница” является подложкой. Не пишите JS в <script>, а используйте methods и все будет хорошо работать.

I was able to resolve this by re-architecting my CSS so I did not have to redefine it in the component page.