vue 获取随机色


获取随机色,vue的使用

    <view class="slip-item" :style="{background:bgColor}" @tap="selectItem()"  @touchstart="touchStart"  @touchend="touchEnd" @touchmove="touchMove"
                v-for="item in 3" :key='item'
            >    
                <view class="slip-itemBox">
                    <view class="slip-head">
                        {{title}}
                    </view>
                </view>
                
            </view>
            
mounted() {
            this.getColor()
        },
        
        methods: {
            // 获取随机色
            getColor(){
                let r = parseInt(Math.random() * 256)
                let g = parseInt(Math.random() * 256)
                let b = parseInt(Math.random() * 256)

                this.bgColor = `rgba(${r},${g},${b},0.3)`
            },
}

只是记录,以备后续有需要


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM