ionic 2
来源:互联网 发布:江苏公务员待遇知乎 编辑:程序博客网 时间:2024/06/06 06:43
/**
* 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.
*
* When running in the web or as a Progressive Web App, Storage will attempt to use
* IndexedDB, WebSQL, and localstorage, in that order.
*
* @usage
* First, if you'd like to use SQLite, install the cordova-sqlite-storage plugin:
* ```bash
* cordova plugin add cordova-sqlite-storage --save
* ```
*
* Next, install the package (comes by default for Ionic 2 apps >= RC.0)
*
* ```bash
* npm install --save @ionic/storage
* ```
*
* Next, add it to the providers list in your `NgModule` declaration (for example, in `src/app.module.ts`):
*
* ```typescript
* import { Storage } from '@ionic/storage';
*
* @NgModule({
* declarations: [
* // ...
* ],
* imports: [
* IonicModule.forRoot(MyApp)
* ],
* bootstrap: [IonicApp],
* entryComponents: [
* // ...
* ],
* providers: [
* Storage
* ]
* })
* export class AppModule {}
*```
*
* Finally, inject it into any of your components or pages:
* ```typescript
* import { Storage } from '@ionic/storage';
* export class MyApp {
* constructor(storage: Storage) {
*
* // set a key/value
* storage.set('name', 'Max');
*
* // Or to get a key/value pair
* storage.get('name').then((val) => {
* console.log('Your name is', val);
* })
* }
* }
* ```
*
* ### Configuring Storage
*
* The Storage engine can be configured both with specific storage engine priorities, or custom configuration
* options to pass to localForage. See the localForage config docs for possible options: https://github.com/localForage/localForage#configuration
*
*
* ```typescript
* import { Storage } from '@ionic/storage';
*
* export function provideStorage() {
* return new Storage(['sqlite', 'websql', 'indexeddb'], { name: '__mydb' }// optional config);
* }
*
* @NgModule({
* declarations: ...,
* imports: ...,
* bootstrap: ...,
* entryComponents: ...,
* providers: [
* { provide: Storage, useFactory: provideStorage }
* ]
* })
* export class AppModule {}
* ```
*/
if you want to adjust the storage order of storage, you can configure like below:
if you want to adjust the storage order of storage, you can configure like below:
export function provideStorage() {
return new Storage(['localstorage','sqlite', 'websql', 'indexeddb']); <--- As you can see here, the first storage is local storage
}
0 0
- ionic 2
- ionic 2 添加service
- ionic 2 使用typescript
- Ionic 2 入门教程
- ionic学习笔记2
- Ionic 2 Tutorial
- ionic 2 常用记录
- ionic 2 实践小结
- ionic 2+ 学习方法
- Ionic
- ionic
- Ionic
- Ionic
- ionic
- Ionic
- ionic
- Ionic
- Ionic
- Java的多线程终止,守护线程
- 欢迎使用CSDN-markdown编辑器
- CALayer简单讲解
- codeforces 785 D Anton and School
- frame 和window的区别
- ionic 2
- EL表达式获取项目根路径
- java模板方法模式
- AJAX->跨域->JSON->JSONP->解决跨域请求
- leetcode 415. Add Strings
- 2016年总结
- 一维数组
- JSON
- 使用idea自定义代码段