简体   繁体   English

React 重用样式 (css/scss)

[英]React reusing styles (css/scss)

I have a .scss file in src/assets/css/button.module.css我在 src/assets/css/button.module.css 中有一个 .scss 文件

simplified content below下面的简化内容

.btn:visited{
    text-transform: uppercase;
    text-decoration: none;
    padding: 15px 40px;
}

I want to use this style in multiple components.我想在多个组件中使用这种样式。 How can i import the css to required component我如何将 css 导入所需的组件

I tried importing this in another scss as below我尝试在另一个 scss 中导入它,如下所示

@import url('../../assets/css/button.module.scss');

But the the styles are not getting loaded.但是样式没有加载。 Any advice please任何建议请

Try using @import '../../assets/css/button.module.scss'尝试使用@import '../../assets/css/button.module.scss'

If does not work try using partials如果不起作用尝试使用部分

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM