IOS Safari 修剪大型 localStorage 数据,IONIC2 应用程序

IOS Safari trims large localStorage data, IONIC2 app

我目前正在开发 Ionic2 应用程序。我需要在本地存储中为用户存储一些问题。问题 json 约为 70kb(在桌面上另存为 .txt 时)。它在桌面上运行良好。但是在 IOS 上查看时,localstorage 被修剪了,没有显示全部值。

您可以看到图像底部的三个点。

有人可以指导我这里出了什么问题吗?我正在使用 localStorage.setItem("question_data",JSON.stringify(data));.

请尝试使用 ionic 的 Storage,它将在 Android 和 iOS.

上使用 sqlite 而不是 localStorage

Storage is an easy way to store key/value pairs and JSON objects. Storage uses a variety of storage engines underneath, picking the best one available depending on the platform. When running in a native app context, Storage will prioritize using SQLite, as it's one of the most stable and widely used file-based databases, and avoids some of the pitfalls of things like localstorage and IndexedDB, such as the OS deciding to clear out such data in low disk-space situations.

这是文档:http://ionicframework.com/docs/v2/storage/