When we conduct modular development, in order to improve the reusability of some styles, we will independently encapsulate the style into a style file (for example
mixins.less
), but when we use it multiple times, we have to import the style file again and again, here Provides a pluginstyle-resources-loader
way to automate the import of style files
Step 1: Terminal
vue add style-resources-loader
, and then select the css preprocessing method you need. I use less here.
Step 2:vue.config.js
Automatically add configuration
in and then in the template file, you can automatically use the style in the file without introducing the corresponding file or Defined style variables or methods out