我正在尝试制作一个电子商务列表页面,左侧栏具有不同的过滤器,右侧栏具有使用ramda和vue的产品。我有2个问题:
(1)我正在尝试将产品价格过滤为1-100。
(2)我无法对已过滤的产品进行分页。
问题1:我传递[0,1,2,3,4,....,99,100],我试图使用“ includes()”从其中过滤掉99,但是代码无法正常过滤JS应该但是我不知道为什么ramda.js只过滤确切的单词或数字。
问题2:在装入产品时,分页工作正常,但是当我进行过滤时,因为我希望每页显示10个项目;它仅在第一页中显示10个项目,并丢弃所有其他已过滤的项目,因此在第一页之后没有页面。
问题1:
return R.pipe(R.pluck('product_prices'), R.uniq)(products_list)
return this.products_list.filter(
prod => (prod.product_prices].some(val => this.filters.includes(val)) )
)
问题2:
if (this.currentPage >= this.totalPages) {
this.currentPage = this.totalPages
}
var index = this.currentPage * this.itemsPerPage - this.itemsPerPage;
return this.filteredProducts.slice(index, index + this.itemsPerPage);
问题1:我想使用ramda和vue从一系列价格中过滤价格。
问题2:应用任何过滤器后,我应该能够看到所有过滤后的产品均已分页。
问题在这一行:
this.resultCount = (!this.activeFilters.length) ? this.products.length : this.activeFilters.length
您不想计算过滤器,但要计算过滤的产品。像这样:
this.resultCount = (!this.activeFilters.length) ? this.products.length : this.filteredProducts.length
您可以在另一个小提琴中看到它。但是下次,请在此处发布您的代码。Fiddle链接是一个不错的选择,但所有相关的内容也应出现在问题中。您发布的代码不足以证明您的问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句