写出微信小程序中的刷新过程代码,此处我们注意到,一次刷新之后重复的是onload()中的代码过程,所以此处我们需要的是复制onload()中的代码
过程如下:
onPullDownRefresh(){//因为我们刷新做的是完全一样的事情所以我们把onload()中的代码复制过来
wx.request({
url: 'https://test-miniprogram.com/api/weather/now',
data: {
city: '广州市'
},
success: res => {
let result = res.data.result
let temp = result.now.temp
let weather =
result.now.weather
console.log(temp, weather)
this.setData({
nowTemp: temp + '°',
nowWeather: weatherMap
[weather],
nowWeatherBackground:
'/images/' + weather + '-bg.png'
})
wx.setNavigationBarColor({
frontColor: '#000000',
backgroundColor:
weatherColorMap[weather]
})
}
})
}