Vue list filtering + list sorting

const arr = 
this.persons.filter((p)=>{     return p.name.indexOf(val) !== -1 }) Do not modify the original data, fold #region      #endregion when both watch and computed can be realized , prefer to use computed ==================== list sorting ========================= sortType: 0 //0 original order 1 descending order 2 ascending order //judging whether to sort if(this.sortType){     arr.sory((p1,p2)=>{         return this.sortType === 1 ? p2.age-p1 .age : p1.age-p2.age;     })     return arr; }














Guess you like

Origin blog.csdn.net/a2285786446/article/details/127493815