Fork自 DCloud / uni-app
体验新版 GitCode,发现更多精彩内容 >>
// 管理账号信息 const USERS_KEY = 'USERS_KEY'; const STATE_KEY = 'STATE_KEY'; const getUsers = function () { let ret = ''; ret = uni.getStorageSync(USERS_KEY); if (!ret) { ret = '[]'; } return JSON.parse(ret); } const addUser = function (userInfo) { let users = getUsers(); users.push({ account: userInfo.account, password: userInfo.password }); uni.setStorageSync(USERS_KEY, JSON.stringify(users)); } export default { getUsers, addUser }