问题描述
我在使用 Ionic 存储时遇到问题.
I'm having problems with the Ionic Storage.
当我登录我的应用程序时,它保存了一些配置对象.我上次检查的是 IndexedDb.
When I log into my app, its saved on storage some configuration objects.On my last check was on IndexedDb.
但是如果我保存任何文件更改或只是刷新页面,有时它会从 IndexedDb 切换到 Web SQL...
But if I save any file changes or simply refresh the page, sometimes it switches from IndexedDb to Web SQL...
我所有的数据都丢失"了,因为数据库是全新的.
All my data is "lost" because the DB is a fresh new one.
任何人都知道它为什么会发生或如何解决.
Anyone knows why its happening or how to solve.
这是我的app.module存储设置
IonicStorageModule.forRoot({
name: '__cds',
driverOrder: ['indexeddb', 'sqlite', 'websql']
})
我怕我编译成一个App后会影响到这个.到目前为止,我只在浏览器开发
I'm afraid the repercussions on this when I compiled into an App.So far I'm only on browser develop
我就是这样设置的
//响应是我从http调用接收的对象
//response is an object I'm receiving from http call
this.storage.set('cds', response).then(() => {
this.goHome();
});
我就是这么理解的
this.storage.get('cds').then(cds => {
this.variable = JSON.parse(cds);
});
看,这不是维护"单个数据库上的存储
See, it's not "mantaining" the storage on a single db
推荐答案
原来问题是 Chrome Web Dev Tools 的一个特性"(我认为).你看,当我刷新应用程序时,我使用的是切换设备工具栏
Turns out the problem is a "feature" (I think) of Chrome Web Dev Tools.You see, when I refresh the app I was using the Toggle Device Toolbar
这有助于网页设计.如果您注意到这个标记为响应式
This helps the web design. If you notice this one is marked as Responsive
由于许多其他原因,我突然将标签更改为 Iphone 大小之一
For a lot of other reasons, I suddenly changed my tab to one of Iphone size
我不知道为什么它会这样工作,但是这个小小的改变不仅仅是改变视口大小......
I don't know why it works like this, but this little change make more than just alter the viewport size...
正在使用的存储库也发生了变化,我的问题开始出现.
The storage base in use changed as well, and my problem begun.
就生产应用而言,这不是问题,因为我认为用户无法在 Chrome 开发工具上切换"视口大小....
In terms of a production App this will not be a problem, as I think the user was not able to "switch" viewport sizes on Chrome Dev Tools....
就是这样.感谢 Marcol 的帮助!!
That's it. Thanks Marcol for your help!!
这篇关于离子存储不需要的改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!