在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);
            }
        }
    }
}
posted @ 2019-10-16 14:27  飞雪连天e^πi+1=0  阅读(7535)  评论(0)    收藏  举报