1.1.5 • Published 4 years ago

lottery-prize v1.1.5

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

安装方法

name of image must be continuous number and start at 1(like:1.png, 2.png)

  • 方法一
<link rel="stylesheet" href="/dist/index.css">
<script src="/dist/prize.js"></script>
  • 方法二
npm i lottery-prize

使用方法

  • 方法一 script标签引入
let game = new Prize(el, options)
game.start(win, num) // 调用开始抽奖方法,传入是否中奖,奖品号码
  • 方法二 npm包管理
import  Prize from 'lottery-prize'
import 'lottery-prize/dist/index.css'
let game = new Prize(el, options)
game.start(win, num) // 调用开始抽奖方法,传入是否中奖,奖品号码

vue中引入

<template>
<div>
  <div style="margin-top: 20px" id="prize-content"></div>
  <span id="btn" @click="start">抽奖</span>
  </div>
</template>

<script>
import  Prize from 'lottery-prize'
export default {
  name: 'test',
  data () {
    return {
      prize: null
    }
  },
  mounted () {
    this.$nextTick().then( _ => {
      this.prize = new Prize(document.querySelector('#prize-content'), {
        imageSrc: '../images',
        pageNum: 4,
        pageSize: 12,
        imageType: 'jpeg'
      });
    })
  },
  methods: {
    start () {
      let win = Math.random() > 0.5 ? true : false
      let num = Math.round(Math.random() * 12 )
      // console.log(win, num)
      this.prize.start(win, num)
    }
  }
}
</script>

参数说明

参数是否必填类型备注
elementString / htmlElementObject可以传入css选择器名,或者dom节点
optionsObject初始化参数
  • options属性
属性是否必填类型备注
imageSrcString,默认值 '../images'图片的路径
pageNumNumber 默认值 4奖品循环几轮
pageSizeNumber 默认值 10参与抽奖的奖品数量
imageTypeString,默认值 'png'图片类型
1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago