【发布时间】:2022-01-18 00:49:14
【问题描述】:
我每次都需要刷新我的购物车页面,当 products.length 为 0 但我不知道如何编写 if 条件时,现在它编写了无法访问的代码。 我觉得这很简单,所以我在这里问。
switch (action.type){
case "REMOVE_PRODUCT":
return products.filter((p) => p.id !== action.productId);
if (products.length === 0) {
window.location.reload();
}
}
【问题讨论】:
标签: javascript html reactjs react-native