小程序 的相关笔记
1.设置缓存:
wx.setStorageSync(‘access_token’, access_token)
获取缓存:
var access_token = wx.getStorageSync(‘access_token’)
2.小程序POST 提交数据
header: {
“Content-Type”: “application/x-www-form-urlencoded”
},
method: ‘POST’,
3.小程序弹出窗 (带选择的);
actioncnt:function(){
wx.showActionSheet({
itemList: ['A', 'B', 'C'],
success: function(res) {
console.log(res.tapIndex)
},
fail: function(res) {
console.log(res.errMsg)
}
})
}
```
4.小程序刷新页面(只限于数据刷新):
if (getCurrentPages().length != 0) {
//刷新当前页面的数据
getCurrentPages()[getCurrentPages().length - 1].onLoad()
}
5.小程序 时间获取:
//昨天的时间
var day1 = new Date();
day1.setTime(day1.getTime()-24*60*60*1000);
var s1 = day1.getFullYear()+"-" + (day1.getMonth()+1) + "-" + day1.getDate();
//今天的时间
var day2 = new Date();
day2.setTime(day2.getTime());
var s2 = day2.getFullYear()+"-" + (day2.getMonth()+1) + "-" + day2.getDate();
//明天的时间
var day3 = new Date();
day3.setTime(day3.getTime()+24*60*60*1000);
var s3 = day3.getFullYear()+"-" + (day3.getMonth()+1) + "-" + day3.getDate();