如何使用VUE JS添加动态分配的ARIA标签的文本

发布于 2025-01-25 11:20:44 字数 194 浏览 2 评论 0原文

我是vue.js和可访问性的新手,

我试图使屏幕读取器宣布一个元素为(“ this是” + person.name)。

我能够用:aria-label =“ person.name”宣布该人。

如何在动态分配的:aria-label周围添加文本?

I am very new to vue.js and accessibility,

I am trying to make an element be announced by the screen reader as ("This is " + person.name).

I was able to announce the person.name with :aria-label="person.name" but I am not able to add text around this.

How do I add text around the dynamically assigned :aria-label?

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

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

发布评论

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

评论(1

妞丶爷亲个 2025-02-01 11:20:44

您是否尝试使用:aria-label =“'this是' + person.name”

new Vue({
  el: "#demo",
  data() {
    return {
      person: { name: "Logan" }
    }
  },
  mounted() {
    console.log(this.$refs.btn)
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
<button ref="btn" :aria-label="'This is ' + person.name">name</button>
</div>

Did you try with :aria-label="'This is ' + person.name"

new Vue({
  el: "#demo",
  data() {
    return {
      person: { name: "Logan" }
    }
  },
  mounted() {
    console.log(this.$refs.btn)
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
<button ref="btn" :aria-label="'This is ' + person.name">name</button>
</div>

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