小程序自动更新功能

小程序自动更新功能

.vue 页面的 script 中添加生命周期,在生命周期内监听页面信息

  • onLoad
		onLoad(options) {this.getUserInfo()this.intervalId = setInterval(() => {this.getUserInfo()}, 3000);},
  • onUnload
		onUnload: function() {// 在页面卸载时清除定时器if (this.intervalId) {clearInterval(this.intervalId)}},