Thinking that after using scoped, the styles between components will not affect each other, then when I override the style of the component in the component library, is it reasonable to use !important in my current component (because the style nesting layer of the header component in the component library Number of depths, using deeper levels is always easier than using !important) Please give me some advice
曾经蜡笔没有小新2017-05-18 10:56:09
It is recommended not to use !important as much as possible. If you use it, you will enjoy development for a while, but later maintenance will not be so satisfactory. There is a class in the outer layer of the component template, and the weight is enough.
大家讲道理2017-05-18 10:56:09
It is strongly recommended not to use !important. In addition, nesting should be used as little as possible, which will affect performance. I would rather write more classes
漂亮男人2017-05-18 10:56:09
Scoped has placed the only restriction on the component. Using important will only affect the content in the component. It doesn’t matter whether you use it or not
怪我咯2017-05-18 10:56:09
scoped is to add a random prefix to the css in the component. All css affected by that random prefix can be used with confidence! important
世界只因有你2017-05-18 10:56:09
!Impotant should not be used unless absolutely necessary. It is really a dangerous thing.
Although scoped has restricted the style to only take effect on elements within the component, problems may also occur within the same component. For example, if you use !important in a relatively large component, problems may occur during future expansion, modification, and maintenance. Son. After all, as time went by, I forgot about this matter.
Of course, if you want to say that you will never forget it, even if it means important, that’s fine. It’s just that you have to write a few more characters for no reason, which is so painful. People like me usually roll around every time I write an extra semicolon. I can't stand it. Adding one more !important means 10 characters, five bytes, and 200 million visits waste a gigabyte of traffic. What a waste, isn't it? :)