How to get data from a component in VueJS
<template>
<div>
<label class="typo__label">Single selecter</label>
<multiselect v-model="internalValue" :options="options" :searchable="false" :close-on-select="false" :show-labels="false" placeholder="Pick a value"> </multiselect>
</div>
</template>
<script>
import Multiselect from 'vue-multiselect'
export default {
components: {
Multiselect
},
props: ['value'],
data () {
return {
internalValue: this.value,
options: ['Select option', 'options', 'selected', 'mulitple', 'label', 'searchable', 'clearOnSelect', 'hideSelected', 'maxHeight', 'allowEmpty', 'showLabels', 'onChange', 'touched']
}
},
watch:{
internalValue(v){
this.$emit('input', v);
}
}
}
</script>
and in your page
<p id="app-two">
<dropdown v-model="selectedValue"></dropdown>
@{{ selectedValue}}
@{{ message }}
</p>
<script>
new Vue({
el: '#app',
data: {
selectedValue: null
message: 'Test message'
}
});
</script>
Here is an example, not using multi-select, but a custom component that implements support for v-model
.