ThomasVdBerge
ThomasVdBerge

Reputation: 8140

Call method from child component

I am using the FlipClock.js Vue Component.

My code looks like the code below, and is called from another vue component:

import { FlipClock } from '@mvpleung/flipclock';
export default {
  ...
  components: {
    FlipClock
  }
}

...

<flip-clock :options="{clockFace: 'Counter', autoStart: false}" />

How can I now manipulate the FlipClock component and for example call the increment method of it?

this.$refs is undefined

Upvotes: 0

Views: 103

Answers (1)

Maxim
Maxim

Reputation: 2391

Your <flip-clock :options="{clockFace: 'Counter', autoStart: false}" /> need to add ref attribute like <flip-clock ref='flipClock' :options="{clockFace: 'Counter', autoStart: false}" />.

After call this.$refs.flipClock.increment()

Upvotes: 2

Related Questions