Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to add text around dynamically assigned aria labels with Vue JS

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading