New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@kafan/vue-turntable

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kafan/vue-turntable

转盘组件

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

TurnTable 转盘组件

介绍

插入转盘组件

组件支持函数调用和组件调用

注意

为了css能够被px2rem识别到并进行rem转换,这里将css提取了出来,请务必记得手动载入样式

组件调用

TurnTable组件可添加props属性后直接插入使用,可自己在组件上添加class或使用className属性自定义类名覆盖样式

import '@kafan/vue-turntable/lib/index.css'

import TurnTable from '@kafan/vue-turntable'

// 全局注册
Vue.use(TurnTable)
// 使用
<template>
    <v-turntable 
        className="test" 
        :lottery-list="lotteryList" 
        @lottery-start="lotteryStart" 
        @lottery-end="lotteryEnd"
        odd-bg-color="#ffd3d3"
        even-bg-color="#fff"
        :duration="1500">
        <template v-slot:goods>
            <span 
                v-for="(item,index) in lotteryList" 
                :key="index" 
                class="testItem" 
                :style="{'width': `${Math.PI * 100 / lotteryList.length}%`,
                'transform':`translateX(-50%) rotate(${(2 * index + 1) * 180 / lotteryList.length}deg)`}"
            >
                {{item.name}}
            </span>
        </template>
    </v-turntable>
</template> 

<script>
export default {
    data(){
        return {
            lotteryList: []
        }
    },
    methods:{
        lotteryStart(fn){
            //do something
        },
        lotteryEnd(reset){
            //do something
        }
    }
}
</script>

props

组件调用时, 支持传入以下 props

参数说明类型默认值备注
lottery-list奖品列表Array[][{name:'',icon:''}]
odd-bg-color奇数列背景色String#fff-
even-bg-color偶数列背景色String#f1deff-
third-bg-color奇数奖品3倍数列背景色String#dcf8fe-
oX圆心x轴坐标Number129-
oY圆心y轴坐标Number129-
radius转盘半径Number129-
className自定义类名String--
duration转盘动画持续时长Number2000毫秒(ms)

事件监听

组件调用时, 会触发以下事件,可供监听回调:

事件返回值触发说明备注
lottery-startlottery[is:转动函数]点击抽奖按钮时lottery参数请传入中奖奖品索引id
lottery-endreset[is:重置函数]转盘动画结束时可执行动画结束后相关回调

插槽使用

本组件有具名插槽goods和btn供使用,即自定义转盘每个奖品项的显示内容以及自定义抽奖按钮

示例

    <template v-slot:goods>
        <p v-for="(item,index) in lotteryList" :key="index">{{item}}</p>
    </template>

    <template v-slot:btn>
        <a class="xxx">按钮文案</a>
    </template>

## 函数调用

```js

import TurnTable from '@kafan/vue-turntable'

TurnTable({
    lotteryList:[{
        name:'xxx',
        icon:'http://xxxx.png'
    },{
        name:'yy',
        icon:'http://yy.png'
    }],
    targetContainer:document.querySelectorAll('.lottery')[0],
    className:'test',
    duration:1000,
    slotScoped:()=>{
        return {
            "btn":{tag:'span', data:{style: {display:'flex','align-items':'center','justify-content':'center',width:'100px',height:'100px',position:'absolute',top:'50%',left:'50%',transform:'translate(-50%,-50%)','border-radius':'100%',background:'blue',color:'#fff','font-size':'18px'}}, text:'test'}
        }
    },
    lotteryStart:(fn)=>{
        fn(1)
    },
    lotteryEnd:(reset)=>{
        alert(111);
        reset()
    }
})

//可赋值到Vue原型上供全局使用
Vue.prototype.$TurnTable = TurnTable

options

函数调用时, 支持传入以下 options

参数说明类型默认值备注
lotteryList奖品列表Array[][{name:'',icon:''}]
oddBgColor奇数列背景色String#fff-
evenBgColor偶数列背景色String#f1deff-
thirdBgColor奇数奖品3倍数列背景色String#dcf8fe-
oX圆心x轴坐标Number129-
oY圆心y轴坐标Number129-
radius转盘半径Number129-
className自定义类名String--
duration转盘动画持续时长Number2000毫秒(ms)
targetContainer插入的容器Objectdocument.body-
lotteryStart抽奖开始回调Function(fn) => {}fn(index)传入中奖奖品索引
lotteryEnd抽奖结束回调Function(reset) => {}reset()可重置转盘
slotScoped插槽函数Function() => {}[() => Object{"name":VNode}]

FAQs

Package last updated on 23 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts