问题描述
我在离子存储方面遇到问题.
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
这就是我的设置方式
//response是我从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开发工具的功能"(我认为).您会看到,当我刷新应用程序时,我正在使用 Toggle Device Toolbar
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!!
这篇关于离子存储不必要的改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!