在vue composition api中:
我有一些定制的产品:
const chair = new Product(...); // lots of information in each product
const table = new Product(...); // lots of information in each product
以及深层对象中引用产品的订单列表:
let example = reactive({
orders: [
{ product: chair, quantity: 2 },
{ product: table, quantity: 1 },
{ product: chair, quantity: 6 },
{ product: table, quantity: 2 },
]
});
我通过example.orders[0].product == chair
->;false
这些是不同的物体.
由于我可以有很多不同的订单和产品包含很多数据,我希望example.orders[].product
保持参考原始产品.
我不要求产品本身具有react 性,因为它们是恒定的.(这是一款Electron 应用程序,只要程序运行,内容就会保持不变)
我只想接受订单.