小程序跨页面数据同步

class DataJs {
  constructor() {
    this.data = {};
  }
  getData(name) {
    if (!name) {
      return null;
    }
    return this.data[name];
  }
  setData(params = {}) {
    for (let i in params) {
      this.data[i] = params[i];
    }
  }
  clearData(name) {
    if (name) {
      delete this.data[name];
      // this.data[name] = null;
    }
  }
  clearAll() {
    this.data = {};
  }
};

export default new DataJs();

你可能感兴趣的:(小程序跨页面数据同步)