The discrepancy between the class selector name in the compiled style when using css module in vue and the class name in dom causes the style not to take effect.

when using css module, the parent component suffixes the class selector of the child component style with the hash suffix, but the html tag is intact, causing the child component to reference no style effect

for example, btn.vue is referenced in header.vue .
Sub-component set .class {background:red} in dom: class= "$style.class" .

becomes

after compilation

style is: .class _? (hash suffix),

dom is: class= "class" .

the two do not match, so the style cannot take effect.

refer to the question page

Apr.29,2021

attach a link: https://www.cnblogs.com/xiaoh.
suggests taking a closer look at

Menu