【Foreword】 Both Vue and React's CSS modular solutions rely on loaders to implement them. In use, Vue uses example: <div> <div class="demo"> <div class="child"></ div> </div> </div> <script> //some code <script/> <style lang="less" scoped> .demo { height: 100px; padding-top: 20px; background-color: grey; /deep/.child { color: red; } } </style> This is how it is used in react (based on css-loader): //test.less .demo { height: 100px; padding-top: 20px; background-color: grey; :global(.child) { color: red } } import styles from './test.less' //some code <div className={styles.demo}> <div class="child"></div> </div> I have to say that vue is more convenient to use. What if you insist on using css-loader in vue to implement this solution of css module? Here we take vue-clie 3.x as an example. Whether in vue's scaffolding Here, in the root directory of the project created by module.exports = { chainWebpack: (config) => { config.devServer .proxy({ '/api': { target: 'http://localhost:3000', pathRewrite: { '^/api': '', }, }, }) .port(9000); config.module .rule('less') .oneOf('normal-modules') .test(/.less$/) .use('css-loader') .tap(options => { return Object.assign(options, { modules: localIdentName: '[name]__[local]___[hash:base64:5]', auto: /\.less$/i, }, }) }); }, }; Actually, you don't need to write this paragraph. By default, the scaffolding of vue-cli has configured the modularization of This is the end of this article about using css-loader to implement css module in vue-cli. For more information about using css module in vue-cli, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! |
<<: Html page supports dark mode implementation
>>: Nginx configuration SSL and WSS steps introduction
Table of contents Preface Modifiers of v-model: l...
There are some differences between filter and bac...
Generally speaking, the mouse is displayed as an u...
register The front-end uses axios in vue to pass ...
Preface Many years ago, I was a newbie on the ser...
Preface In MySQL, we can use the EXPLAIN command ...
Sometimes we need to remotely run programs on the...
1. First, create the corresponding folder accordi...
Preface In many management and office systems, tr...
MySQL official website: https://www.mysql.com/dow...
1. First download from the official website of My...
In the previous article, we have implemented loca...
Recently, I encountered the need to embed a player...
Hardware View Commands system # uname -a # View k...