Skip to content

ShakeDice 组件

介绍

摇骰子

基础用法

vue
<template>
  <nut-shakedice ref="dice" :id="id"></nut-shakedice>
  <div @click="jump" class="demoBtn">摇动</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'

const dice = ref()
const id = ref()
function jump() {
  id.value = 2
  dice.value.shake()
}
</script>

<style lang="scss">
  body {
    width: 100%;
    height: 500px;
    text-align: center;
    background: url("//img12.360buyimg.com/imagetools/jfs/t1/95587/33/21814/218186/61e0015aE05e5fa32/e367632953cc3633.png")
      no-repeat bottom !important;
  }
  .nutbig-shakedice {
    margin: 70px auto;
  }
  .demoBtn {
    margin: 200px auto 0;
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    background: linear-gradient(
      135deg,
      rgba(240, 22, 14, 1) 0%,
      rgba(240, 37, 15, 0.8) 69.83950099728881%,
      rgba(240, 78, 14, 1) 100%
    );
    border-radius: 20px;
    box-shadow: 0 4px 10px 0 rgba(240, 37, 15, 0.3);
  }
</style>

Props

参数说明类型默认值
time旋转时间string1
speed旋转速度,msnumber3000
id中奖的 id(1 为 1 点,依次类推)number1

Events

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

Exposes

方法名说明类型
shake骰子开始摇动()=> true

MIT Licensed