ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## .js ``` Page({ data:{ liked:false }, onLoad(options){ var storage = wx.getStorageSync("liked") //设置缓存 if(storage){ this.setData({ liked: storage }) } }, onLike(){ var liked=!this.data.liked; wx.setStorageSync('liked',liked); // var storageValue = wx.getStorageSync('liked') this.setData({ liked }) }, unLike(){ wx.clearStorageSync() //清除缓存 } }) ``` ## .wxml ``` <image src="{{liked?'/images/like.png':'/images/unlike.png'}}" catchtap="onLike"></image> ```