我应该使用哪种HTML5离线存储解决方案在我的网络应用程序中存储用户注释? [英] Which HTML5 offline storage solution should I use for storing user notes in my web app?

查看:86
本文介绍了我应该使用哪种HTML5离线存储解决方案在我的网络应用程序中存储用户注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Chrome应用,用户可以在其中创建和编写笔记(纯文本),我希望这些笔记可以离线保存。

I'm writing a Chrome app in which users can create and write notes(plain text), I'd like to the notes to be saved offline.

我了解到html5有几种存储解决方案: localStorage Web SQL DB 应用程序缓存。我想知道你如何选择它们的建议,考虑它们提供的尺寸,速度和使用的便利性。

I've learned that there are several storage solutions from html5: localStorage, Web SQL DB, Application Cache. I'd like to know your advice on how to choose from them, considering the size they offer, the speed, and the convenience of use.

推荐答案

localStorage 是迄今为止最简单的解决方案,也是您应该用于此任务的解决方案。它允许你存储字符串,所以只要你的数据可以表示为字符串 - 它将起作用(通常的做法是在保存之前将非字符串数据转换为json,然后再解析)。

localStorage is by far the simplest solution and it's the one you should use for this task. It allows you to store strings, so as long as your data can be represented as strings - it will work (usual practice is to convert non-string data to json before saving, then parse is back).

WebDB 是您的普通数据库。如果需要跨多个表对数据运行复杂查询,则可以使用它。对于存储笔记,这将是一种矫枉过正。

WebDB is your normal database. If you need to run complicated queries on your data across multiple tables, then you can use it. For storing notes it would be an overkill.

应用程序缓存是完全不同的东西,我看不出来你可以在这里申请。它用于缓存html页面和资源。

Application cache is something completely different, I don't see how you can apply it here. It is for caching html pages and resources.

这篇关于我应该使用哪种HTML5离线存储解决方案在我的网络应用程序中存储用户注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆