[英]Object.assign() doesn't structure my array of objects the way it is
You are calling Object.assign
and passing an array as an argument.您正在调用
Object.assign
并将数组作为参数传递。 Array's can still accept properties the same ways objects do.数组仍然可以像对象一样接受属性。 But if you want to add the object to the array, use
Array.prototype.push
instead.但是,如果您想将 object 添加到数组中,请改用
Array.prototype.push
。
if (!this.favoriteCoins.some(e => e.cryptoName === coinId)) {
this.favoriteCoins.push({cryptoName: coinId})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.