[Vuejs]-Refreshing url by vue.js

0👍

Started using vue.js recently, so bear with me. I think you need to pass the timeoutId into clearTimeout. Since you haven’t done that, setTimeout() is running even after the component has been unmounted.

This should work for you!

Edit: Kissu, why did you delete my answer, rewrite it, and then claim an edit? Reported.

export default {
  data: () => ({
    timeoutId: null,
  }),
  methods: {
    reloadPage() {
      window.location.reload();
    },
    reload() {
      this.timeoutId = setTimeout(this.reloadPage, 10000);
    },
  },
  mounted() {
    this.reload();
  },
  beforeUnmount() {
    clearTimeout(this.timeoutId);
  },
};

Leave a comment