zoukankan      html  css  js  c++  java
  • 小程序 数据缓存

    Page(
    {
    data: {
    // text:"这是一个页面"
    storageContent: '',
    storageSyncContent: ''
    },
    onLoad: function (options) { // 页面初始化 options为页面跳转所带来的参数
    },

    /** * 异步存储 */
    listenerStorageSave: function () {
    //以键值对的形式存储 传进去的是个对象
    wx.setStorage(
    {
    key: 'key',
    data: '我是storeage异步存储的信息',
    success: function (res) {
    console.log(res)
    }
    })
    },
    /** * 异步取信息 */
    listenerStorageGet: function () {
    var that = this; wx.getStorage({
    //获取数据的key
    key: 'key',
    success: function (res) {
    console.log(res)
    that.setData({
    //
    storageContent: res.data
    })
    },
    /** * 失败会调用 */
    fail: function (res) { console.log(res) }
    })
    },
    /** * 清除数据 */ listenerStorageClear: function () { var that = this; wx.clearStorage({ success: function (res) { that.setData({ storageContent: '' }) } }) },
    /** * 数据同步存储 */
    listenerStorageSyncSave: function () { wx.setStorageSync('key', '我是同步存储的数据') },
    /** * 数据同步获取 */
    listenerStorageSyncGet: function () {
    //
    var that = this;
    var value = wx.getStorageSync('key')
    this.setData({ storageSyncContent: value })
    },
    /** * 清除同步存储数据 */
    listenerStorageSyncClear: function () { wx.clearStorageSync() }, onReady: function () {
    // 页面渲染完成
    },
    onShow: function () {
    // 页面显示
    },
    onHide: function () {
    // 页面隐藏
    },
    onUnload: function () {
    // 页面关闭
    }
    })
  • 相关阅读:
    组合总和
    子集Ⅱ
    子集
    全排列Ⅱ
    全排列
    填充下一个结点下一个Next结点
    把二叉树转化成累加树
    二叉树的左叶子之和
    高速C/C++编译工具ccache
    【转载】如何用U盘制作Ubuntu启动盘
  • 原文地址:https://www.cnblogs.com/dianzan/p/7803264.html
Copyright © 2011-2022 走看看