JS实现水果机老虎机的抽奖效果

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Big Mouth Machine</title>
    <style>
        html {
            height: 100%;
            background: linear-gradient(#f50, #f55, #fff);
        }

        #box {
            padding: 40px 0;
            width: 500px;
            margin: auto;
        }

        #btn1 {
            padding: 0.6em 2.5em;
            font-size: 1em;
            border-radius: 10px;
            border-color: rgba(0, 0, 0, 0.4);
            color: #fff;
            background: linear-gradient(#eee, #f50);
        }
    </style>
</head>

<body>
    <div id="box"></div>
    <div class="" style="text-align: center;">
        <button id="btn1">摇 杆</button>
    </div>
    <script type="module">
        export default class SlotMachines{
            //私有属性
            #grids=[];
            #activeIndex=0;
            //动态设置激活样式的方法
            #setActiveStyle;

            // 这里做一些初始化的工作...
            constructor(object,window){
                if(typeof object.id!='string') throw new Error('id is undefined')
                const { document } = window;
                //按自己实际需求传入,可修改对应的样式,任你千变万化,我有一定之规。
                object=Object.assign({
                    cols:3,
                    rows:3,
                    styleBg:{
                        margin:'auto',
                        border: '2px solid #f50',
                        backgroundColor:'#f50',
                        borderRadius:'5px'
                    },
                    styleGrid:{
                        color:'#fff',
                        borderColor:'#faa',
                        backgroundColor:'#faa',
                        borderRadius:'5px'
                    },
                    styleActive:{
                        color:'#000',
                        borderColor:'#af0',
                        backgroundColor:'#aaff00',
                    },
                    styleCenter:{
                        color: '#fff',
                        backgroundColor:'#f50',
                        textAlign:'center'
                    },
                    centerText: '老虎机\nBig Mouth Machine',
                    goods:[],
                },object);
                object.cols=Math.max(objec
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值