# ant-mini-dice-roller

> 支付宝小程序摇骰子

Latest version **1.0.3** (published 2019-10-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install ant-mini-dice-roller
pnpm add ant-mini-dice-roller
yarn add ant-mini-dice-roller
bun add ant-mini-dice-roller
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-10-31 |
| First published | 2019-04-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | 0326, crazymousethief, misaka |
| Keywords | 支付宝, 小程序, 摇骰子, 抽奖, mini-program |

## Links

- npm: https://www.npmjs.com/package/ant-mini-dice-roller
- npm.io page: https://npm.io/package/ant-mini-dice-roller

## Recent versions

- 1.0.3 (latest) — 2019-10-31
- 1.0.2 — 2019-06-13
- 1.0.1 — 2019-06-13
- 1.0.0 — 2019-04-03

## README

# 摇骰子 小程序组件

![](https://gw.alicdn.com/tfs/TB1tNrMdYvpK1RjSZPiXXbmwXXa-259-216.gif)

## Install

### tnpm

```dash
yarn add ant-mini-dice-roller
```

## Usage

### json

```json
{
  "usingComponents": {
    "diceroller": "ant-mini-dice-roller/es/component/index"
  }
}
```

### js

``` js
Page({
  data: {
    awardImg: '',
    awardName: '',
    tipText: '',
  },
  onStart() {
    toast('开始摇')
    this.setData({
      tipText: '正在抽奖...'
    });
    setTimeout(() => {
      this.setData({
        awardImg: 'https://gw.alicdn.com/tfs/TB1JsqGbHPpK1RjSZFFXXa5PpXa-289-298.png',
        awardName: '1等奖'
      })
    }, 2000);
  },
  onFinish() {
    toast('摇完啦')
    this.setData({
      tipText: `抽奖结果：${this.data.awardName}`
    });
  }
});
```
### xaml
```html
<view class="container">
  <diceroller
    clickMode="true"
    awardImg="{{awardImg}}"
    onStart="onStart"
    onFinish="onFinish"
  >
    <view slot="button">外部组件摇一摇按钮</view>
  </diceroller>
  <view class='tip-text'>{{tipText}}</view>
</view>
```

### API
属性 | 类型 | 默认值 | 含义 |
--- | --- | --- | ---
width | Number | 318 | 组件宽度(rpx)
height | Number | 300 | 组件高度(rpx)
background | String | #FFF | 背景色
rollTime | Number | 3000 | 摇骰子时间（毫秒）
rollImg | String | [查看](https://gw.alipayobjects.com/zos/rmsportal/cuSVBODjFpqiVMgnLiXK.png) | 摇奖时逐帧图片
initImg | String | [查看](https://gw.alicdn.com/tfs/TB1JsqGbHPpK1RjSZFFXXa5PpXa-289-298.png) | 初始化骰子图片
onStart | Func | - | 开始回调
onFinish | Func | - | 结束回调

---
_Source: https://npm.io/package/ant-mini-dice-roller · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
