相关疑难解决方法(0)

选中时如何正确使用 MUISwitch“条”颜色的主题覆盖?

仔细阅读源代码后,我尝试了以下操作,该操作有效但在控制台中生成警告。

const myTheme = createMuiTheme({
  overrides: {
    MuiSwitch: {
      checked: {
        "& + $bar": {
          opacity: 1.0,
          backgroundColor: "rgb(129, 171, 134)" // Light green, aka #74d77f
        }
      }
    }
  }
});
Run Code Online (Sandbox Code Playgroud)

我得到的错误/警告是:

Warning: Material-UI: the `MuiSwitch` component increases the CSS specificity of the `checked` internal state.
You can not override it like this: 
{
  "checked": {
    "& + $bar": {
      "opacity": 1,
      "backgroundColor": "rgb(129, 171, 134)"
    }
  }
}

Instead, you need to use the $ruleName syntax:
{ …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui

4
推荐指数
1
解决办法
1407
查看次数

标签 统计

material-ui ×1

reactjs ×1