我有兴趣构建一个小型离线 web 应用程序,我正在寻找一些建议。这是我想要它做的基础知识
- 创建最初只有名称和文本字段的报告
- 列出、编辑和删除这些笔记
- 理想情况下,我想稍后在报告中添加更多字段
localstorage 是在本地存储此类数据的好选择吗?如果是这样,任何人都可以指导我在javascript中与它交互的命令的完整列表吗?例如 setItem、getItem 等。
谢谢。
我有兴趣构建一个小型离线 web 应用程序,我正在寻找一些建议。这是我想要它做的基础知识
localstorage 是在本地存储此类数据的好选择吗?如果是这样,任何人都可以指导我在javascript中与它交互的命令的完整列表吗?例如 setItem、getItem 等。
谢谢。
localstorage will work just fine for this, but don't think of it as a robust solution.. It's just a basic key/value store and won't be very performant with thousands of complex things going on.
Check out the excellent Dive into HTML5 guide on localstorage: http://diveintohtml5.info/storage.html
Yes localstorage would be perfect for you application. It would allow your application to have no need to connect to a server at all. Keep in mind that local storage does have maximums on the amount of data that can be stored.
EDIT:
Using JSON.stringify()
on can convert complex javascript objects to json which can be storage and retrieved with ease inside of local storage.