Skip to content

Instantly share code, notes, and snippets.

@brunokunace
Created March 20, 2019 15:00
Show Gist options
  • Save brunokunace/25931e67b5d1ff95aa342a866edcf0a1 to your computer and use it in GitHub Desktop.
Save brunokunace/25931e67b5d1ff95aa342a866edcf0a1 to your computer and use it in GitHub Desktop.
<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