如何将复选框ARIACHECK旋转到布尔值?

发布于 2025-02-13 16:37:14 字数 1490 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猥琐帝 2025-02-20 16:37:14

不确定我正确理解了这个问题,但是默认情况下,复选框值似乎是字符串,这就是为什么它是白色的。
要将其转到布尔值,您可以创建一个变量,然后检查值是否为字符串true,分配为变量,否则分配false。

const checkboxValue = ariaChecked === 'true' ? true : false;

或速记

const checkboxValue = ariaChecked === 'true';

Not sure I understand the question correctly but it seems that checkbox value will by default be a string, that is why it is white.
To turn it to boolean you can create a variable and then check if values is the string true, the assign true to the variable, otherwise assign false.

const checkboxValue = ariaChecked === 'true' ? true : false;

or shorthand

const checkboxValue = ariaChecked === 'true';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文