const [product, setProduct] = useState([]);
const [filters, setFilters] = useState({
category: '',
brand: '',
type: '',
});
const displayProduct = product
.filter(prod =>
prod.category.includes(filters.category) &&
prod.brand.includes(filters.brand) &&
prod.type.includes(filters.type)
)
.map(product => {
return(
<div className='imageContainer ' key={product.id}>
<img src={PopularOne} className="image"/>
<div className='productName'>
<Link style={{ textDecoration:'none' }} to="/productsDetails" state={{ product:product }}>{product.productName}</Link>
</div>
<div className='productPrice'>
<h3 >RM{product.productPrice}</h3>
</div>
</div>
)
})
<input type="checkbox" onClick={() => {setFilters({...filters,category: 'abc',})}}/><label>abc</label><br/>
<input type="checkbox" onClick={() => {setFilters({...filters,category: 'test',})}}/><label>test</label>
我有一个过滤器,可以过滤产品的类别,品牌,和类型。我面临的问题是我只能过滤一个类别的时间,我想选择多个类别和过滤多个类别的时间。我该怎么做?
1条答案
按热度按时间prdp8dxp1#