XiaoLin1995/vue-fortune-wheel

Ask: How to trigger rotation programaticaly

nomut opened this issue · 2 comments

nomut commented

Hi, first of all, thanks for making this awesome component.

I want to ask, is there any function to start rotation?
I tried this and got :
caught TypeError: this.$refs.fortuneWheel.onRotateStart is not a function

my application use websocket to set prizeId and I need that function to trigger rotation, is it posible?

I use:
vue@3.2.41
vue-fortune-wheel@2.0.2

sorry for my bad english :)
Thank you!

First, update to the latest version.

npm install vue-fortune-wheel@latest

Then, You can call the startRotate method.

example:

<template>
  <FortuneWheel
    ref="wheelEl"
    :prizes="[]"
   />
</template>

<script setup>
import { ref, onMounted } from 'vue'
import FortuneWheel from 'vue-fortune-wheel'
import 'vue-fortune-wheel/style.css'

const wheelEl = ref()

onMounted(() => {
  wheelEl.value.startRotate() // Can start rotation
})
<script>
nomut commented

It works!

Many thanks @XiaoLin1995