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')
}
})