将CSS导入React组件后未添加样式

Shibasis Sengupta

我在CSS文件(TextBoxStyle.css)中拥有此类-

.CustomTextBox{
width: 100%;
border-radius: 4px;
height: 30px;
}

然后我试图在React组件中使用它-

import React from 'react';
import ReactDOM from 'react-dom';
import styleClass from  './TextBoxStyle.css';

export class TextBox extends React.Component{

render(){      
                return  (
                <input className={styleClass.CustomTextBox}>
                </input>
                );
}
}

我已经通过webpack安装了所有必需的加载程序,因此项目构建成功。

但是,类'CustomTextBox'没有显示在我的最终html页面中。

请让我知道是否需要详细说明。非常感谢您的帮助。

史考特

如果您绝对不需要引用CustomTextBox,则可以尝试直接导入CSS,如下所示:

import './TextBoxStyle.css';

然后像这样更改输入的className:

<input className="CustomTextBox">

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章