使用style-loader没报错但没有应用样式

配置文件
图片描述

原本的css文件

html, body{
    width: 100%;
    height: 100%;
}

.root{
    width: 100%;
    height: 100%;
}

//stage
.stage{
    position: relative;
    width: 100%;
    height: 680px;
}

//image
.img-sec{
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #ddd;
}

//controller
.controller-nav{
    position: absolute;
    left: 0;
    bottom: 30px;
    z-index: 101;
    width: 100%;
    text-align: center; 
}

样式文件已插入页面
图片描述

.index_root___3csDm,这个码是怎么生成的?只有html和body的样式应用上了,其余没有,请问是怎么回事?

阅读 1.8k
1 个回答

因为你开启了css-module, 把css-loader的options去掉试试

如果要使用css-module的话,就要使用css-in-js的语法,比如

import styles from './main.css'

之后直接使用styles来访问css里面的类名

关于css-module的有缺点就不说了,网上很多

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题