@processmaker/vue-form-elements
Version:
Reusable VueJS Based Form Elements styled with Bootstrap 4
23 lines (22 loc) • 513 B
JavaScript
export default {
name: 'hasDefaultOptionKeyMixin',
computed: {
valueOrDefault() {
return this.value || this.options.defaultOptionKey;
},
},
watch: {
'options.defaultOptionKey': {
immediate: true,
handler(value) {
!this.value ? this.$emit('input', value) : null;
}
},
value: {
immediate: true,
handler() {
!this.value && this.options.defaultOptionKey ? this.$emit('input', this.options.defaultOptionKey) : null;
}
},
},
}