gpt4 book ai didi

button - (如何)我可以更改 F# Fable Elmish 中禁用按钮的字体颜色吗?

转载 作者:行者123 更新时间:2023-12-02 03:12:32 25 4
gpt4 key购买 nike

我尝试通过样式颜色设置颜色,但它仅在未禁用时更改颜色。使用或不使用 Fulma 是否有可能?

Button.button
[
Button.Disabled true
Button.Props [
Style [ Color "#000000" ] ]
//if … then
Button.OnClick (fun _ -> dispatch Msg)
]
[ str "Text here" ]

作为最后的手段,我将使用带有调度函数的 if 条件,这样按钮就不起作用了。

提前致谢。

最佳答案

@nilekirk 解决方案确实是使用内联样式执行此操作的正确方法。

但是如果您的应用程序中有很多按钮,它会使代码很快变得非常冗长。

另一个解决方案是将一些 CSS 直接应用于所有禁用的按钮,或者如果您不希望所有按钮都出现这种行为,您可以添加自定义类。

应用于应用程序的所有按钮

CSS 代码:

.button[disabled] {
background-color: black !important;
}

F# 代码:

Button.button
[
Button.Disabled true
Button.OnClick (fun _ -> dispatch Msg)
]
[ str "Text here" ]

使用自定义类来选择哪个按钮应具有此行为

CSS代码

.button.custom-disabled[disabled] {
background-color: black !important;
}

F# 代码

Button.button
[
Button.CustomClass "custom-disabled"
Button.Disabled true
Button.OnClick (fun _ -> dispatch Msg)
]
[ str "Text here" ]

关于button - (如何)我可以更改 F# Fable Elmish 中禁用按钮的字体颜色吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57219077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com