在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