【发布时间】:2018-05-05 02:55:21
【问题描述】:
我需要编写自定义过滤搜索、排序和分页属性,因为我的产品不能依赖任何开箱即用的解决方案,主要是因为我需要在表格中显示图像、图标、按钮和 URL。将其视为带有图片和购买链接的产品列表页面。
我的问题是如何链接多个计算属性?
示例
对于过滤搜索:
computed: {
filteredProds:function() {
return this.prodlist.filter(prod => {
return prod.name.toLowerCase().includes(this.search.toLowerCase())
})
}
为了对表格进行排序,我有这个计算属性以及一种进行排序的方法。
myprods.sort((a,b) => {
let modifier = 1;
if(this.currentSortDir === 'desc') modifier = -1;
if(a[this.currentSort] < b[this.currentSort]) return -1 * modifier;
if(a[this.currentSort] > b[this.currentSort]) return 1 * modifier;
return 0;
});
【问题讨论】:
标签: javascript vue.js