【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
What to do if you forget Windows Server 2008R2 So...
Find information Some methods found on the Intern...
Secondly, the ranking of keywords is also related ...
js realizes the special effect of clicking and dr...
1. Log in to MySQL database mysql -u root -p View...
1 Background JDK1.8-u181 and Tomcat8.5.53 were in...
In this article, I will explain the relevant cont...
Data migration needs to be imported from MySQL to...
This article introduces the method of using CSS3 ...
Recorded the installation of mysql-8.0.12-winx64 ...
Edit /etc/docker/daemon.json and add the followin...
The textarea tag size is immutable Copy code The c...
1. Nginx service foundation Nginx (engine x) is d...
In daily operation and maintenance work, nginx se...