1

I'm trying to reduce the value of a data property in every 1 second as follows:

  data() {
    return {
      timer: null
    }
  },

  mounted() {
    this.timer = 50;
    window.setInterval(() => {
      this.$set(this, 'timer', this.timer - 1)
    }, 1000);
  },

https://jsfiddle.net/eywraw8t/8179/

In the Vue devTool, the timer is not automatically updated. However, in the jsfiddle, the output is getting updated. Is this reactive? If not, how can I make it reactive?

4
  • It's working as expected, what's the problem? Commented Apr 2, 2018 at 20:20
  • When I open up the vue devtool, the timer value is not updating. I'm wondering if it's usual or the reactivity is lost. Commented Apr 2, 2018 at 20:22
  • If the reactivity was lost, who would be updating the DOM do you think? Commented Apr 2, 2018 at 20:24
  • Possible duplicate of Why doesn't the data get updated in Vue Dev Tools? Commented Apr 2, 2018 at 21:07

1 Answer 1

0

As @connexo already mentioned in the comment section timer is indeed reactive. This is why it changes its value in the template.

The only reason for this I could think of is that you don't include timer in the component template in your environment. There's a related Github issue describing that so far if there's no DOM elements affected by data, vue-devtools won't be updated either.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.