[Vuejs]-Getting selected vue value into data return

2👍

It’s very bad pattern, but you have no choice working with library that does not emit ANY events.

DON’T DO IT EVER AGAIN!!!

<datepicker ref="datepicker" @click.native="method"></datepicker>
data() {
  return {
    value: ''
  }
},
methods: {
  method() {
    this.value = this.$refs.datepicker.pickedValue
  },
},

1👍

Try to use v-model directive to bind your datepicker to that data property pickedValue as follows :

<div v-cloak v-if="isScheduledTask">
  <datepicker value="" name="pickedValue" v-model="pickedValue" ></datepicker>
</div>

script :

data() {
    return {
       pickedValue: ''
    }
 }

Leave a comment