Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
Switch Case for date data type in Vue.JS

Greetings all and pardon my novice for I am just a mere beginner. I am trying to sort by ascending/ descending by using an @click and switch case. The method below however, does not sort at all. The very method works for every other data type other than the date (of course), which is why I am confused as this indicates yet another problem with the date data type specifically. I know date data types are very finnicky, so if any advice could be spared it would be greatly appreciated. Here is some supporting code for this problem. If anything else is needed please let me know.

 <th @click="sort('date')" scope="col">
            Date
            <div v-if="sortedKey == 'date'">
              <i v-if="sortAscending" class="fas fa-arrow-circle-up"></i>
              <i v-else class="fas fa-arrow-circle-down"></i>
            </div>
          </th>

export default {
  name: "ServiceTable",
  data() {
    return {
      pageCount: 10,
      query: "",
      localEntries: [],

      sortedKey: "",
      sortAscending: false,
    };
  },

computed: {
    computedList() {
      if (this.query.length == 0)
        return this.localEntries.slice(0, this.pageCount);
      let filteredList = this.localEntries
        .filter((element) => {
        .slice(0, this.pageCount);

      return filteredList;
    },
  },

sort(key) {
      this.sortAscending = !this.sortAscending;
      this.sortedKey = key;

      switch (key) {
      
      case "date":
          if (this.sortAscending)
            this.localEntries.sort((a, b) =>
              a.date > b.date ? 1 : -1
            );
          else
            this.localEntries.sort((a, b) =>
              a.date < b.date ? 1 : -1
            );
          break;
      }
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda