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