Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

235
Views
¿Cómo ordenar el selector de rango de fechas de Vuetify?

Tengo un selector de rango de fechas vuetify como se muestra:

 <v-menu ref="effectiveDateMenu" v-model="effectiveDateMenu" :close-on-content-click="false" transition="scale-transition" offset-y max-width="290px" min-width="auto"> <template v-slot:activator="{ on, attrs }"> <v-text-field label="Time Period" v-model="effectiveDateRange" filled dense rounded @*:rules="[v => !!(v && v.length) || 'Rating period is required']"*@ v-bind="attrs" v-on="on" range required :class="toggleEdit ? 'locked' : 'editable'" :readonly="toggleEdit"></v-text-field> </template> <v-date-picker v-model="dates" no-title @@input="datesPicked()" range></v-date-picker> </v-menu>

Luego use la siguiente propiedad calculada para devolver los valores al campo de texto; sin embargo, no puedo obtener las fechas en orden. Solo puede elegir dos fechas y si elige la fecha más nueva primero, completa el campo de texto con ese valor primero, incluso si uso la función de clasificación en el modelo v para el selector de fecha. Cualquier ayuda sería apreciada.

 computed: { effectiveDateRange: function () { // `this` points to the vm instance return this.dates.map((element) => { var d = new Date(element); return `${d.getUTCMonth() + 1}/${d.getUTCDate()}/${d.getUTCFullYear()}`; }).sort(function (a, b) { // Turn your strings into dates, and then subtract them // to get a value that is either negative, positive, or zero. return new Date(b.date) - new Date(a.date); }).join(' - ') } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Dado que los elementos de la matriz de dates son cadenas en el formato ISO 8601 (YYYY-mm-dd o YYYY-mm), en los que los valores de fecha y hora están ordenados de mayor a menor importancia, simplemente puede ordenar la matriz:

 effectiveDateRange: function() { return this.dates.sort().join(' - '); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!