首页 > 学院 > 开发设计 > 正文

ionic 数据存储 StorageHelper

2019-11-08 00:24:35
字体:
来源:转载
供稿:网友

官网说明

import { Injectable } from "@angular/core";import { Storage } from '@ionic/storage';@Injectable()export class StorageHelper {    constructor(public storage: Storage) { }    GET(name, type) {        return this.storage.get(name).then(data => {            let v = data;            if (type == "json" && v != "") {                v = JSON.parse(v);            }            return v;        });    }    SET(name, val) {        if (typeof val == "object") {            val = JSON.stringify(val);        }        this.storage.set(name, val);    }    Remove(name) {        this.storage.remove(name);    }}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表