Sort an array in Vue.js

前端 未结 5 800
时光取名叫无心
时光取名叫无心 2020-12-13 00:02

How can I sort an array by name or sex before displaying it in a v-for loop? https://jsfiddle.net/rg50h7hx/

5条回答
  •  春和景丽
    2020-12-13 00:21

    Easy way; You can use computedArray instead of array

    computed: {
    computedFonksiyon() {
      this.arrays.sort(function(x, y) {
        return y.name- x.name;
      });
      return this.arrays;
    }
    }
    

提交回复
热议问题