我有一个正在运行的 NativeScript 应用程序,现在我想在按下按钮时更改按钮的背景颜色(以便用户可以看到,他确实按下了按钮)。经过一番谷歌搜索后,我发现 documentation .所以我尝试将这些应用到我的代码中(遗憾的是我没有通过 TS 初始化我的按钮,所以我不能使用 btn = new buttonModule.Button();
行。
我的 html:
<Button [text]="'SIGNIN'|translate" (onTap)="passCredentials()"></Button>
我的CSS:
Button {
background-color: rgba(255, 230, 0, 1);
font-weight: bold;
margin-left: 10;
margin-right: 10;
padding: 10;
height: 50;
margin-top: 30;
margin-bottom: 25;
}
Button:pressed {
background-color: red;
}
这就是我的尝试,但他既没有抛出错误也没有改变背景颜色。我需要手动告诉他在这些类(class)之间切换吗?我怎么能那样做?
最佳答案
尝试使用 highlighted
伪选择器:
Button:highlighted{
background-color: red;
}
关于javascript - 如何在 NativeScript 中使用按钮样式选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46276770/