Take the following example code:
new Vue({
el: '#app',
data: {
name: 'Test'
},
computed: {
hover: function () {
//I'd like to use the "data-prefix" here instead of "XXX"
return this.name + "XXX";
}
}
})
<script src="https://unpkg.com/vue"></script>
<div id="app">
<select>
<option data-prefix="ABC" v-bind:title="hover">1</option>
<option data-prefix="XXX" v-bind:title="hover">2</option>
<option data-prefix="YYY" v-bind:title="hover">3</option>
</select>
<input type="text" name="name" v-model="name">
</div>
Here I have a legacy application that generates a select with varios options in it. I've modified the legacy app to put all information I need into "data-" attributes(plus add "v-bind").
Now I'd like to use this information in various ways in my Vue control, in this particular example I'd like to use the "data-prefix" in the title attribute on each option in my selection.
However I don't know how to access that property from the computed property. Is there a way to do this with Vue?
I've look at the documentation for this, and I don't see this noted anywhere. Has this been done anywhere else?