Search code examples
vue.jsvuejs2quasar-frameworkquasar

limiting date with quasar v1


I am using quasar date component with limiting dates. The documentation says to use options prop to be supplied with an array or function.

<template>
  <div class="q-pa-md">
    <div class="q-gutter-md">
      <q-date
        v-model="date"
        :options="options"
      />

      <q-date
        v-model="date"
        :options="optionsFn"
      />

      <q-date
        v-model="date"
        :options="optionsFn2"
      />
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      date: '2019/02/01',
      options: [ '2019/02/01', '2019/02/05', '2019/02/06', '2019/02/09', '2019/02/23' ]
    }
  },

  methods: {
    optionsFn (date) {
      return date >= '2019/02/03' && date <= '2019/02/15'
    },

    optionsFn2 (date) {
      const parts = date.split('/')
      return parts[2] % 2 === 0
    }
  }
}
</script>
 

The problem is that I am not able to pass any other argument in the optionsFn function.


Solution

  • since options takes in a function call but you are passing options= the return result of that function is not allowed you can fix it to :options="date => optionsFn(date, 'test ')" and it will work as you want