第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

【九月打卡】第5天 使用 Vue 實(shí)現(xiàn)基礎(chǔ)的 CSS 過渡與動畫效果

標(biāo)簽:
Vue.js

课程名称:2022持续升级 Vue3 从入门到实战 掌握完整知识体系

课程章节:4-1 使用 Vue 实现基础的 CSS 过渡与动画效果,4-2 使用 transition 标签实现单元素组件的过渡和动画效果(1)

主讲老师:Dell


课程内容:

今天学习的内容包括: 使用 Vue 实现基础的 CSS 过渡与动画效果,使用 transition 标签实现单元素组件的过渡和动画效果。

动画效果知识点:
1. v-enter-from:入场前状态效果
2. v-enter-active 入场时状态效果
3. v-enter-to 入场结束,离场开始状态效果
4. @keyframes 动画关键帧属性:0%, 25%,表示动画执行的阶段百分比
5. 动画只需要定义 v-enter-active / v-leave-active
示例代码:
<style>
    /* 动画
    @keyframes leftToRight {
        0% {
            transform: translateX(-100px);
        }
        50% {
            transform: translateX(-50px);
        }
        0% {
            transform: translateX(0px);
        }
    }
    .animation {
        animation: leftToRight 3s;
    } */

    /* 过渡
    .transition {
        transition: 3s background-color ease;
    }
    .blue {
        background: blue;
    }
    .green {
        background: green;
    } */
    .transition {
        transition: 2s background-color ease;
    }
</style>

<script>
    const app = Vue.createApp({
        data() {
            return {
                styleObj: {
                    background: 'blue'
                }
            }
        },
        methods: {
            handleClick() {
                if(this.styleObj.background === 'blue') {
                    this.styleObj.background = 'green';
                } else {
                    this.styleObj.background = 'blue'
                }
            }
        },
        template: `
            <div>
                <div class="transition" :style="styleObj">hello world</div>
                <button @click="handleClick">切换</button>
            </div>
        `
    });

    const vm = app.mount('#root');
</script>

示例代码2:
<style>
    @keyframes shake {
        0% {
            transform: translateX(-100px)
        }
        50% {
            transform: translateX(-50px)
        }
        100% {
            transform: translateX(50px)
        }
    }
    .hello-leave-active {
        animation: shake 3s;
    }
    .hello-enter-active {
        animation: shake 3s;
    }
</style>

<script>
    // 单元素,单组件的入场出场动画
    const app = Vue.createApp({
        data() {
            return {
                show: false
            }
        },
        methods: {
            handleClick() {
                this.show = !this.show;
            }
        },
        template: `
            <div>
                <transition name="hello">
                    <div v-if="show">hello world</div>
                </transition>
                <button @click="handleClick">切换</button>
            </div>
        `
    });
  
    const vm = app.mount('#root');
</script>

课程收获:

今天只学了第四章的前两节,对 Vue 实现动画效果有了更深的了解,可以去试着给自己的博客做一个黑暗模式的切换效果。明天中秋节也要继续努力啊,学无止境。

今日课程学习时间大约花费 15 分钟。

https://img1.sycdn.imooc.com//631b5e3d0001344319190939.jpg

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評論
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊有機(jī)會得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

舉報

0/150
提交
取消