我试图将可读存储作为默认值添加到可写存储中,这样用户在打开应用程序时就会看到一些默认值。
我有一个大的
readable
百货商店
taskStore
,其中包含具有任务信息的不同对象,如下所示:
import { writable, readable } from "svelte/store";
// The video directories together with the corresponding frame counts should be placed here
export const taskStore = readable(
[
{
imageDir: '100159',
frameCount: 50,
labels: [
{ frame: 10, x: 125, y: 60 },
{ frame: 10, x: 125, y: 60 },
{ frame: 10, x: 125, y: 60 },
]
},
{
imageDir: '100589',
frameCount: 50,
labels: []
}
]
)
所以我尝试添加第一个值
taskStore
到可写
currentTaskStore
,就像这样:
export const currentTaskStore = writable([taskStore[0]])
但它不起作用,我得到了
undefined
当我尝试在其他组件中使用此存储时。是否可以使用
writable
存储复杂的对象,还是只用于基本体?