<button class="navbar__dropdown-toggle" :aria-expanded="active"></button>
我正在尝试绑定(bind)
aria-expanded
到下拉菜单的状态。不幸的是,当使用屏幕阅读器(视障人士)时,听写并不表示它是一个非扩展的下拉菜单,因为虚假属性已被删除。有没有办法强制保留虚假属性?
最佳答案
看起来像来自 W3C spec ,aria-expanded
的值可以是真或假。所以在你的模板中你可以做到这一点。
<button class="navbar__dropdown-toggle" :aria-expanded="active ? 'true' : 'false'">expanded</button>
工作 example .
关于vuejs2 - 你如何强制 Vue 使用 v-bind 显示虚假属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45204191/