我正在尝试从 React/Redux 中的 props.location.search 中分离出值。我已成功获得 mixOne 拆分,但我似乎无法返回数量值。这是我的代码:
const mixOne = props.location.search
? String(props.location.search.split("mixOne=")[1])
: "None";
const quantity = props.location.search
? Number(props.location.search.split("=")[1])
: 1;
这是生成的 URL:
const addToCartHandler = () => {
props.history.push(
`/Cart/${productId}?quantity=${quantity}?mixOne=${mixOne}`
);
};
正如您所看到的,当我需要选择的值时,数量返回 null
米琪卡哇伊
相关分类