Vue project webpack packaged, typed the code wrong, and only part of the code error?

as detailed in the title:

encounter such a weird problem (really weird), I am also drunk!

the problem lies in:

Local debugging before the project is packaged: everything is normal, the switch between the two routing pages, different background images can follow the switch

after the project is packaged: opens the project with the local server, and the two routing pages are switched (because the text of the two different pages is switched during the switch), but a background image of the two pages is not switched (both pages have a different background image) * *. Open the developer tool, switch between the two pages, and find that the text has changed in element , but the url of the background image remains the same. so I deeply suspect that webpack typed the code wrong when packing, and it was a partial error. I am completely drunk

just found the difference: because the rendering of both pages introduces the same HTML component, but different view pages render data dynamically. But what does this have to do with? How to solve it?

do you think it"s so weird that you don"t even give a rule of finding a problem?

when I encounter such a problem, there is nothing I can do. I look forward to seeing a lot of advice from you and waiting to hear from you.

Mar.20,2021

solve the question raised by yourself:
although the root cause of the solution lies in the scoped attribute of < style scoped >, even if you understand its relevant features, it still can not explain

.

(1) A component with a scoped attribute can maintain the current component style from being affected by other components

(2) parent component with scoped attribute added, child component element style cannot be modified (no child component plus attribute scoped, because scoped can only maintain the current component element)

(3) A parent component without scoped attribute can modify the child component style

(4) A parent component with a scoped attribute is added, and a child component with a scoped attribute can also be forcibly controlled by:. A > .b or .a / deep/

in css preprocessing.

although all three of the above are true, the irrationality lies in the situation in which the third item cannot be explained

problem: three parent components with different contents (without scoped attribute) all apply the same child component template and populate the child component template with parent content.

however, three different parent components all set different styles for the same element of the child component, and the style is normal when switching between the three parent components for the first time; but in the second round of switching, the style of the same element does not change with the switch. instead, the last style is switched in the first round, no matter how many rounds are switched later.

because of the bizarre problem above, I finally chose item (4) to solve

.
Menu