Assume I have this :
<select class="form-control" name="gateway">
<option data-type="typeA" value="1">Test String</option>
<option data-type="typeB" value="2">Test String</option>
<option data-type="typeC" value="3">Test String</option>
</select>
<span>@{{ typeMapper(data-type) }}</span>
Here is my Vue.js script :
const app = new Vue({
el: '#vue-app',
data: {},
methods: {
typeMapper: function (type) {
var array = {
'typeA':'You selected Type A',
'typeB':'You selected Type B',
'typeC':'You selected Type C',
};
return array[type];
}
}
});
Now how can I get data-type values in Vue.js ?
I want to pass selected option data-type value to Vue.js typeMapper method and show the result in the span tag.
I don't know how to pass data-type value to Vue.js !
P.S:
I'm using Vue.js 2