Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何更改styles.js中禁用按钮的颜色_Javascript_Css_Reactjs_Sass - Fatal编程技术网

Javascript 如何更改styles.js中禁用按钮的颜色

Javascript 如何更改styles.js中禁用按钮的颜色,javascript,css,reactjs,sass,Javascript,Css,Reactjs,Sass,我在styles.js中有一个按钮 export const Button = styled.button` background: ${(props) => (props.isSubtract ? `#0F4379` : `#F5F6F9`)}; border-radius: 30%; cursor: pointer; margin-top: 4px `; 当按钮被禁用时,我想将颜色从常规默认的灰色更改为黄色。我见过很多使用css的方法,但是因为我已经有了一个style

我在styles.js中有一个按钮

export const Button = styled.button`
  background: ${(props) => (props.isSubtract ? `#0F4379` : `#F5F6F9`)};
  border-radius: 30%;
  cursor: pointer;
  margin-top: 4px
`;
当按钮被禁用时,我想将颜色从常规默认的灰色更改为黄色。我见过很多使用css的方法,但是因为我已经有了一个styles.js文件,所以我也不想添加css文件

有关于如何在.js文件中更改它的提示吗

我尝试补充:

  &:disabled {
    background: #FFFF00;
  }

但这并没有帮助

为什么不传递一个名为disabled的道具,并像处理背景一样进行操作呢

在任何情况下,我相信您正在使用样式化组件

:disabled {
  ...  
}

应该做这个把戏

你在用图书馆吗?如果是这样的话,你应该编辑你的文章并将其添加为标记,因为你似乎在使用一些框架,比如React和样式化组件,加上SASS或者更少,或者某种预处理器。为那些框架和库添加标签很重要,否则人们会看着你的代码说,“这不是有效的JS和CSS!”谢谢,现在已经添加了标签,我添加了
:disabled{background:#ffffff00;}
,但它不起作用