【发布时间】:2021-05-05 04:17:49
【问题描述】:
我无法从可写存储中读取所有数据:
Error: 'store' is not exported by src\stores.js, imported by src\components\Users.svelte
商店:
import {subscribe} from 'svelte/internal'
import {writable} from 'svelte/store'
export const fooStore = (key, initial) => {
const foo = localStorage.getItem(key)
const data = foo ? JSON.parse(user) : initial
const store = writable(data, () => {
const unsubscribe = store.subscribe(value => {
localStorage.setItem(key, JSON.stringify(value))
})
return unsubscribe
})
return store
}
观点:
<script>
import {store} from '../stores.js'
</script>
<table>
<thead></thead>
<tbody>
{#each $store as foo}
<tr>
<td>foo.bar</td>
<td>foo.qaz</td>
</tr>
{/each}
</tbody>
</table>
【问题讨论】:
标签: svelte-3