使用这样的扩展运算符时,我收到错误
Cannot redeclare block-scoped variable 'price'
。
const drink = {
id: 'xhs8Pla',
name: 'Lemonade',
};
const price = {
sale: 99,
full: 129,
};
const mergedDrink = { ...drink, { ...price } };
为什么会出现这个错误?
const drink = {
id: 'xhs8Pla',
name: 'Lemonade',
};
const price = {
sale: 99,
full: 129,
};
const mergedDrink = { ...drink, priceKey: { ...price } };
或
const drink = {
id: 'xhs8Pla',
name: 'Lemonade',
};
const price = {
sale: 99,
full: 129,
};
const mergedDrink = { ...drink, ...price};