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

TypeScript Setup documentation needed #44

Open
pattrickrice opened this issue Jun 6, 2019 · 1 comment
Open

TypeScript Setup documentation needed #44

pattrickrice opened this issue Jun 6, 2019 · 1 comment

Comments

@pattrickrice
Copy link

I have created a simple timer component in using typescript, but the timer isn't started. Any idea what I'm doing wrong?

<script lang="ts">
import { Component, Vue, Prop } from 'vue-property-decorator';
import { mixin as VueTimers } from 'vue-timers';

@Component({ mixins: [VueTimers] })
export default class ApplicationStatus extends Vue {
  private time: string = new Date().toString();

  timers: {
    tick: { time: 2000; autostart: true; repeat: true };
  };

  tick() {
    this.time = new Date().toString();
    console.debug(new Date());
  }
}
</script>
@scottwestover
Copy link

I ran into this issue as well, and the only way I could get the timer to work was by setting the timers property directly on the $options property.

Here is an example that is works:

<script lang="ts">
  import { Component, Vue } from 'vue-property-decorator';
  import { mixin as VueTimers } from 'vue-timers';

  @Component({
    name: 'App.vue',
    mixins: [VueTimers],
  })
  export default class App extends Vue {
    constructor() {
      super();
      (this.$options as any).timers = {
        log: { time: 1000, autostart: true, repeat: true },
      };
    }

    log() {
      console.log('hello world');
    }
  }
</script>

It's not the best, but it did allow us to get the timer working for now.

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

2 participants