Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't work with component props #45

Open
paulocoutinhox opened this issue Jun 20, 2019 · 4 comments
Open

Don't work with component props #45

paulocoutinhox opened this issue Jun 20, 2019 · 4 comments

Comments

@paulocoutinhox
Copy link

Hi,

Im trying set interval dynamically from props:

props: {
    interval: {
      type: Number,
      default: 10000
    }
},
timers: {
    getRemoteData: {
      time: this.interval,
      autostart: true,
      repeat: true,
      immediate: true
    }
},

But the timer is firing with interval infinite. If i change "this.interval" to "10000" it work normally.

Can anyone help me?

Thanks.

@masongzhi
Copy link
Contributor

you can use watch

watch: {
  interval(val) {
    this.$timers.getRemoteData.time = val;
  }
}

@paulocoutinhox
Copy link
Author

I tried, but don't work. It fire the request each second:

  props: {
    interval: {
      type: Number,
      default: 10000
    }
  },
  timers: {
    getRemoteData: {
      autostart: true,
      repeat: true,
      immediate: true
    }
  },
  watch: {
    interval(val) {
      this.$timers.getRemoteData.time = val;
    }
  },

:(

@masongzhi
Copy link
Contributor

oh I'm sorry, I have a wrongly written
image

this will be right

watch: {
  interval(val) {
    this.timers.getRemoteData.time = val;
    this.$timer.restart('getRemoteData');
  }
}

@jordanmarshall12
Copy link

I am having issues with component props as well.

props: ["name", "location", "delay"], timers: { animateStat: { time: this.delay, autostart: false, repeat: false } }

This is giving me a console error of Uncaught TypeError: Cannot read property 'delay' of undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants