Created
March 20, 2019 15:00
-
-
Save brunokunace/25931e67b5d1ff95aa342a866edcf0a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<q-select | |
v-model="selected" | |
:float-label="floatLabel" | |
filter | |
radio | |
autofocus-filter | |
:options="customOptions"/> | |
</div> | |
</template> | |
<script> | |
export default { | |
props: { | |
floatLabel: { | |
default: 'Serviço' | |
}, | |
value: { | |
default: null | |
}, | |
customOptions: { | |
default: null | |
} | |
}, | |
data () { }, | |
methods: { | |
emiteSelecionado (newValue, oldValue) { | |
if (!newValue && !oldValue) { | |
return | |
} | |
this.$emit('selected', newValue) | |
} | |
}, | |
watch: { | |
selected (newValue, oldValue) { | |
console.log('emiteSelecionado', newValue, oldValue) | |
this.emiteSelecionado(newValue, oldValue) | |
} | |
}, | |
computed: { | |
selected: { | |
get: function () { | |
if (this.value && this.value.toString().length > 0) { | |
console.log('get computed selected', this.value) | |
return this.value | |
} | |
return null | |
}, | |
set: function (value) { | |
console.log('set computed selected', value) | |
this.$emit('input', value) | |
} | |
} | |
} | |
</script> | |
<style> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment