小程序跨页面数据同步
2019-04-15 本文已影响0人
loewe0202
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();