在vue中使一个el-card背景逐渐变化的的例子(应用场景,提醒用户)


<el-card shadow="hover" style="height:400px;width:100%" ref="elCard" v-bind:style="elCard">

</el-card>
 
export default {
    data() {
        return {
            elCard: {
                background: "#c32623"
            },
            level: 1,
            hexArr: ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e']
        }
    },

 

    created() {
        bus.$emit('showMonitor', this.nav);
        this.flashColor();
    },

 

    methods: {
        flashColor() {
            var color="#FF00";
            this.elCard.background = color+this.hexArr[this.level]+this.hexArr[this.level];
            console.log(this.elCard.background);
            this.level++;
            if(this.level >= 16){
                clearTimeout(this.flashColor);
            }else{
                setTimeout(this.flashColor,300);
            }
        }
    }
}


免责声明!

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



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