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
?
Advertisement
Answer
Did you try with :aria-label="'This is ' + person.name"
JavaScript
x
11
11
1
new Vue({
2
el: "#demo",
3
data() {
4
return {
5
person: { name: "Logan" }
6
}
7
},
8
mounted() {
9
console.log(this.$refs.btn)
10
}
11
})
JavaScript
1
4
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
2
<div id="demo">
3
<button ref="btn" :aria-label="'This is ' + person.name">name</button>
4
</div>