2018-01-21
微信缓存
-
wx.storage
remove移除一个,clear是清除全部缓存
不清空会永远存在,不能超过10MB
// showModal: function (postsCollected, postCollected){
// var that = this;
// wx.showModal({
// title: '收藏',
// content: postCollected?'收藏该文章?':'取消收藏?',
// showCancel: 'true',
// cancelText: '取消',
// cancelColor: '#333',
// confirmText: '确定',
// confirmColor: '#405f80',
// success: function (res){
// if(res.confirm){
// wx.setStorageSync('posts_Collected', postsCollected);
// that.setData({
// collected: postCollected
// })
// }
// }
// })
// }// this.showModal(postsCollected, postCollected);
-
交互反馈:
(1)wx.showToast :可以自动消失
success/loading 对号,等待
success/fail/compled:function(){
}可以写相应的东西
(2)wx.showModal:一直显示 -
异步
调试困难,不建议使用。
需要异步的业务,才需要用。
同步缺陷:耗时长
异步好处:会立刻走完,缺陷:繁琐
getStorage在异步中没后缀,同步中加Sync -
音乐播放
不能用本地文件 -
监听事件
-
生命周期函数:
onLaunch
onShow
onHide
home键后,onLaunch不会执行
7.清除缓存
问题:调换主业之后 detail页的图片没有