小程序开发 缓存的应用

xhml

<view catchtap="onCollectionTap" style="background:green" class="sotrge1" >读取缓存</view>
<view catchtap="onShareTap" style="background:red" class="sotrge2">移除缓存</view>

JS

//获取应用实例
// var postsData=require('../../data/posts-data.js');
var app = getApp()
Page({
data: {

},
onLoad: function(option){
console.log(1);
// this.setData({
// postData:postData
// })
// 添加或修改缓存
// wx.setStorageSync("key", "喝水")
wx.setStorageSync("key", "吃饭")
},
onCollectionTap:function(event){
var game=wx.getStorageSync('key')
console.log(game)
},
onShareTap:function(event){
wx.removeStorageSync('key')
}
})

posted @ 2017-09-04 22:56  ThisCall  阅读(306)  评论(0编辑  收藏  举报