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)`
            },
}

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

你可能感兴趣的:(vue 获取随机色)