Skip to content
On this page

快速开始

安装依赖

sh
# react 或 vue
npm install lattice-lottery-new --save

# uni-app
npm install uni-lattice-lottery --save

需要适配 uni-app 框架的抽奖组件可前往 https://www.npmjs.com/package/uni-lattice-lottery 查看。

按需引入

js
// react 或 vue
import LotteryGrid from 'lattice-lottery-new/LotteryGrid'

// uni-app
import LotteryGrid from 'uni-lattice-lottery/lib/LotteryGrid.vue'

const list = [
  {
    label: "华为Mate 60 Pro+",
  },
  {
    label: "1000元现金红包",
  },
  {
    label: "三等奖",
  },
  {
    label: "500元现金红包",
  },
  {
    label: "谢谢参与",
  },
  {
    label: "六等奖",
  },
  {
    label: "7等奖",
  },
  {
    label: "8等奖",
  },
]

// 初始化
oLotteryGrid = new LotteryGrid({
  element: '.LotteryGrid', // dom class name or id name
  list,
  onend: (val) => {
    console.log("结束", val)
  },
  onsubmit: () => {
    oLotteryGrid.go(4) // index position, start at 0
  }
})