var interval;
在 onLoad: function()里面加
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
var that = this;
interval = setInterval(function() {
that.getMyCommune();
console.log("5秒了----------------------------------------------------")
}, 3000)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
clearInterval(interval)
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
clearInterval(interval)
},
即可完成