html - 如何解决 toast 上“有一个可访问的名称”的可访问性错误?
问题描述
在吐司(弹出通知)上解决此错误的正确方法是什么?例如名字?aria-labelledby? 是描述通知中的内容还是组件是什么?
我正在使用https://bootstrap-vue.org/docs/components/toast
这呈现了这样的东西
<div role="alert" aria-live="assertive" aria-atomic="true">
<div tabindex="0">
<button type="button" aria-label="Close">×</button>
<div>
<p>Some notification text</p>
</div>
</div>
</div>
解决方案
以下是解决它的两种方法:
- 如果您有一个包含 toast 标题的特定 HTML 元素,请给该元素一个 id 并使用该 id 作为
aria-labelledby
父 elementNode 中的值,例如
<div aria-labelledby="title" role="alert" aria-live="assertive" aria-atomic="true">
<h3 id="title">I am the title</h3>
...
</div>
- 您可以只使用
aria-label
父节点元素上的属性,例如:
<div aria-label="Your subscription is about to expire" role="alert" aria-live="assertive" aria-atomic="true">
...
</div>
总之,它的作用是;它以一种摘要的形式告诉屏幕阅读器弹出窗口的内容,就像我们在添加标签时快速掌握输入字段的全部内容一样。
推荐阅读
- scheme - 取数字的子集并检查它们是否加起来是 Scheme 中的目标总和?
- ios - Xcode 12 通用静态库
- php - 通过 PHPMailer 发送电子邮件
- css - 如何在 Material UI Grid 中设置自定义间距边距值
- reactjs - 使用 react 和 mattrial-ui 创建的自定义组件中不显示初始值
- python - 所选项目在 QListView 中没有变化
- python - 逐行列出字典条目
- spring - 多个 Log4j.xml 配置取决于 Spring 的范围
- api - 参数“targetingCriteria”对于 LinkedIn 营销 API 的受众计数无效
- python - Pytube 设置分辨率