Skip to content

ShakeDice 组件

介绍

摇骰子。

基础用法

html
<template>
  <nut-shakedice ref="diceEl" :id="id"></nut-shakedice>

  <nut-button @click="shake()">摇动</nut-button>
</template>
ts
import type { ShakeDiceInst } from "nutui-uniapp";

const diceEl = ref<ShakeDiceInst>();

const id = ref();

function shake() {
  id.value = 2;
  diceEl.value.shake();
}

API

Props

参数说明类型可选值默认值
time旋转时间(单位:s)number-1
speed旋转速度(单位:ms)number-3000
id中奖的 id(1 为 1 点,依此类推)number-4

Events

事件名说明类型
end骰子摇动结束() => void

Exposes

通过 ref 可以获取到 ShakeDice 实例并调用实例方法。

名称说明类型
shake骰子开始摇动() => void

MIT Licensed