css module solves a problem in the end

 

  css module solves the problem?

  In short, let you through the import introducing css to the project, only acts on the current module, does not act on the overall situation, to avoid contamination of the global style

 

  Two kinds of writing

  Global wording: Import './index.scss'; ( do not recommend this wording of coupling, covering the pattern of the other modules easily, good maintenance)

  Local wording: Import style from './index.scss'; (the recommended wording, the style perfect decoupling between the modules, let it act only on the current module, independently of each other, which will help to maintain)

 

 Reproduce the scene

 The A block and B respectively introduced into the global and local manner in a module css style files, A to an element in the font style module added color to red color: red;

 B module style elements are added to the font color to blue color: blue, the result is not only not in force, but also the font color to blue,

 And the introduction of the code are not wrong manner, and finally found partition A style module cover B module style

 

 How to configure (webpack.config.js configure modules: true)

 

 

 

 

 

 

  

Guess you like

Origin www.cnblogs.com/tu-0718/p/12124677.html