setStorage

  1. //设置本地存储
  2. uni.setStorage({
  3. // 保存为本地存储
  4. key:'add-input',
  5. // 需要存储的内容,只支持原生类型、及能够通过 JSON.stringify 序列化的对象
  6. data:JSON.stringify({
  7. content:this.content,
  8. imageList:this.imageList
  9. })
  10. })

getStorage

  1. //获取本地存储
  2. uni.getStorage({
  3. key:'add-input',
  4. // 通过success函数得到返回数据
  5. success: (res) => {
  6. console.log(res)
  7. }
  8. })

removeStorage

  1. // 清空本地存储信息
  2. uni.removeStorage({
  3. key:'add-input'//要清楚信息的key
  4. })