svelte-3 - 无法从可写 Svelte 存储中读取数据
问题描述
我无法从可写存储中读取所有数据:
Error: 'store' is not exported by src\stores.js, imported by src\components\Bar.svelte
Svelte 商店:
import {subscribe} from 'svelte/internal'
import {writable} from 'svelte/store'
export const barStore = (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 {barStore} from '../stores.js'
</script>
<table>
<thead></thead>
<tbody>
{#each $store as foo}
<tr>
<td>foo.bat</td>
<td>foo.shit</td>
<td>foo.crazy</td>
</tr>
{/each}
</tbody>
</table>
解决方案
推荐阅读
- javascript - JavaScript 对象属性包括空格字符
- python - 带有 HEVC 编解码器的 cv2.VideoWriter() 文件格式 .mp4
- sql - 从表中返回一列中的值大于下一列但相邻列中的相应值较小的行
- javascript - 清除旧的间隔 id 计数器后继续增长
- c - 读取时出现分段错误
- python-3.x - 带有 ORM 的 SQLAlchemy 异步引擎无法执行基本查询
- reactjs - ContextProvider => Context APi : 儿童动态渲染
- intershop - 应用程序之间意外的购物篮共享
- android - 颤振)图标的状态不能立即改变(编辑)
- c# - 需要在 Windows 启动时从 WPF UI 设置控制台应用程序