尝试通过scss为className设置react-select的样式,className是不显示

时间:2019-11-24 19:33:04

标签: css reactjs react-select

我正在尝试使用CSS方法来对react-select(v3)进行样式设置,但没有成功。我确实设置了包装容器的样式,但是内部组件甚至没有出现在由组件本身应用和覆盖的开发工具中。没有。为什么会这样,我在做什么错呢?

在使用它的组件中,我仅导入组件本身

import CreatableSelect from "react-select/creatable";

<CreatableSelect
            value={this.getCurrentValue(this.state.value, this.state.options)}
            options={this.state.options}
            placeholder={this.props.formComponentData.placeholder}
            onChange={e => this.handleChange(e.value)}
            onCreateOption={this.handleCreate}
            menuIsOpen={true}
            className="select-search-container"
            classNamePrefix="select-search"
          />

我的scss导入了main.scss

@import '../components/SelectSearch';

因此background-color适用于position,如果我使用!important,那么即使使用.select-search__control!important还是没出现

.select-search-container {
  position: sticky;
  background-color: deepskyblue;
}

.select-search__control {
  height: 2.75rem;
  padding: 0 measure(half) !important;
  border: 1px solid red !important;
  background-color: deepskyblue !important;
  border-radius: 0 !important;
}

对为什么有任何想法吗?

0 个答案:

没有答案