最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue2過渡標(biāo)簽transition使用動(dòng)畫方式

 更新時(shí)間:2024年07月25日 09:52:26   作者:打不著的大喇叭  
這篇文章主要介紹了Vue2過渡標(biāo)簽transition使用動(dòng)畫方式,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

注意:動(dòng)畫必須使用v-if || v-show配合

1、Vue2配Css3實(shí)現(xiàn)

我們需要使用 過渡 標(biāo)簽 <transition> :

<transition name="hello" appear>
      <h1 v-show="isShow">你好??!</h1>
</transition>
 
:appear="true" [值需要的是布爾值,所以需要用v-bind綁定] 也可以直接寫 【appear】
appear使用效果是:打開頁面立馬執(zhí)行一次過來的動(dòng)畫

css3方案一:在樣式style標(biāo)簽里面設(shè)置動(dòng)畫

【給來和走的樣式的名字定義為 v-enter-active | v-leave-active,設(shè)置name的值,需要把v 改成它】

<style>
h1 {
  background-color: orange;
}
/* 如果過渡標(biāo)簽加了name屬性,下面的v需要改為name的值 
.v-enter-active {
  animation: gbase 1s;
}
.v-leave-active {
  animation: gbase 1s reverse;
}
*/
.hello-enter-active {
  animation: gbase 1s;
}
.hello-leave-active {
  animation: gbase 1s reverse;
}
@keyframes gbase {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0px);
  }
}
</style>

注意:vue解析的時(shí)候 <transition> 就沒有了

源碼

<template>
  <div>
    <button @click="isShow = !isShow">顯示/隱藏</button>
    <!--//todo 使用動(dòng)畫 [ 標(biāo)簽必須使用v-if||v-show才行 ]
      //todo 1、使用 過渡 標(biāo)簽 <transition> 【里面有一個(gè)屬性name 標(biāo)志它的名字】
      //todo 2、在樣式style標(biāo)簽里面設(shè)置動(dòng)畫
      //todo 3、給來和走的樣式的名字定義為 v-enter-active | v-leave-active 【設(shè)置name的值,需要把v 改成它】
     -->
    <!-- //? 注意 vue解析的時(shí)候 <transition> 就沒有了 -->
    <!-- //todo :appear="true" [值需要的是布爾值,所以需要用v-bind綁定] 也可以直接寫 【appear】
         //* appear 使用效果是:打開頁面立馬執(zhí)行一次過來的動(dòng)畫 -->
    <transition name="hello" appear>
      <h1 v-show="isShow">你好?。?lt;/h1>
    </transition>
  </div>
</template>
<script>
export default {
  name: "Test",
  data() {
    return {
      isShow: true,
    };
  },
};
</script>
<style>
h1 {
  background-color: orange;
}
.hello-enter-active {
  animation: gbase 1s;
}
.hello-leave-active {
  animation: gbase 1s reverse;
}
@keyframes gbase {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0px);
  }
}
</style>

其他屬性樣式

<transition>標(biāo)簽 里面只能使用一個(gè) DOM 標(biāo)簽

使用 <transition-group> 可以里面放多個(gè)標(biāo)簽使用動(dòng)畫

【但是里面加動(dòng)畫的標(biāo)簽需要加 唯一標(biāo)識(shí)key

    <transition-group name="hello" appear>
      <h1 v-show="isShow" key="1">你好??!</h1>
      <h1 v-show="!isShow" key="2">我不好啊!</h1>
    </transition-group>

css3方案2

<style>
h1 {
  background-color: orange;
  /* transition: 0.5 linear; */
}
todo 進(jìn)入的起點(diǎn)
.hello-enter {
  transform: translateX(-100%);
}
 todo 進(jìn)入的終點(diǎn)
.hello-enter-to {
  transform: translateX(0px);
}
 todo 離開的起點(diǎn)
.hello-leave {
  transform: translateX(0px);
}
 todo 離開的終點(diǎn)
.hello-leave-to {
  transform: translateX(-100%);
}
 
簡寫 :進(jìn)入的起點(diǎn) 就是 離開的終點(diǎn)
.hello-enter,
.hello-leave-to {
  transform: translateX(-100%);
}
.hello-enter-active,
.hello-leave-active {
  或者寫在需要加動(dòng)畫的標(biāo)簽里面
  transition: 0.5 linear;
}
簡寫 :進(jìn)入的終點(diǎn) 就是 離開的起點(diǎn)
.hello-enter-to,
.hello-leave {
  transform: translateX(0px);
}
</style>

2、vue2配合 animate庫使用動(dòng)畫

npm install animate.css : 安裝并使用動(dòng)畫庫

import "animate.css"; 引入該庫

設(shè)置

name="animate__animated animate__bounce"

https://animate.style/里面找動(dòng)畫,把動(dòng)畫名稱賦值給enter-active-class 、leave-active-class這兩個(gè)屬性

    <transition-group
      name="animate__animated animate__bounce"
      appear
      enter-active-class="animate__jackInTheBox"
      leave-active-class="animate__fadeOut"
    >
      <h1 v-show="isShow" key="1">你好??!</h1>
    </transition-group>

源碼

<template>
  <div>
    <button @click="isShow = !isShow">顯示/隱藏</button>
 
    <!-- // todo 2、設(shè)置 name="animate__animated animate__bounce" -->
    <!-- // todo 3、去https://animate.style/ 里面找動(dòng)畫 -->
    <transition-group
      name="animate__animated animate__bounce"
      appear
      enter-active-class="animate__jackInTheBox"
      leave-active-class="animate__fadeOut"
    >
      <h1 v-show="isShow" key="1">你好?。?lt;/h1>
    </transition-group>
  </div>
</template>
// npm install animate.css : 安裝并使用動(dòng)畫庫
<script>
// todo 1、因?yàn)槭且粋€(gè)樣式,可以直接引入文件
import "animate.css";
 
export default {
  name: "Test",
  data() {
    return {
      isShow: true,
    };
  },
};
</script>
<style>
h1 {
  background-color: orange;
  /* transition: 0.5 linear; */
}
</style>

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue登錄密碼驗(yàn)證MD5加密實(shí)踐

    Vue登錄密碼驗(yàn)證MD5加密實(shí)踐

    文章主要描述MD5的特點(diǎn)、原理和使用方法,特點(diǎn)包括固定長度、容易計(jì)算、抗修改和強(qiáng)抗碰撞,使用方法包括安裝js-md5、引入js文件、放到原型等,最后給出一個(gè)使用示例,用于密碼驗(yàn)證
    2026-04-04
  • vue.js多頁面開發(fā)環(huán)境搭建過程

    vue.js多頁面開發(fā)環(huán)境搭建過程

    利用 vue-cli 搭建的項(xiàng)目大都是單頁面應(yīng)用項(xiàng)目,對于簡單的項(xiàng)目,單頁面就能滿足要求。這篇文章主要介紹了vue.js多頁面開發(fā)環(huán)境搭建 ,需要的朋友可以參考下
    2019-04-04
  • Vue實(shí)現(xiàn)單行刪除與批量刪除

    Vue實(shí)現(xiàn)單行刪除與批量刪除

    這篇文章主要介紹了Vue實(shí)現(xiàn)單行刪除與批量刪除,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • vuex的使用和簡易實(shí)現(xiàn)

    vuex的使用和簡易實(shí)現(xiàn)

    這篇文章主要介紹了vuex的使用和簡易實(shí)現(xiàn),幫助大家更好的理解和使用vuex,感興趣的朋友可以了解下
    2021-01-01
  • Vue移動(dòng)端下拉加載更多數(shù)據(jù)onload實(shí)現(xiàn)方法淺析

    Vue移動(dòng)端下拉加載更多數(shù)據(jù)onload實(shí)現(xiàn)方法淺析

    這篇文章主要介紹了Vue移動(dòng)端下拉加載更多數(shù)據(jù)onload實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-02-02
  • 在Vue3中創(chuàng)建和使用全局組件的實(shí)現(xiàn)方式

    在Vue3中創(chuàng)建和使用全局組件的實(shí)現(xiàn)方式

    在前端開發(fā)中,Vue.js 是一個(gè)廣泛使用的框架,因其靈活性和強(qiáng)大的功能,得到許多開發(fā)者的喜愛,Vue 3 的發(fā)布為這一框架帶來了很多新的特性和改進(jìn),在本文中,我們將詳細(xì)討論如何在 Vue 3 中創(chuàng)建和使用全局組件,并通過示例代碼展示具體實(shí)現(xiàn)方式,需要的朋友可以參考下
    2024-07-07
  • 解決vue數(shù)據(jù)不實(shí)時(shí)更新的問題(數(shù)據(jù)更改了,但數(shù)據(jù)不實(shí)時(shí)更新)

    解決vue數(shù)據(jù)不實(shí)時(shí)更新的問題(數(shù)據(jù)更改了,但數(shù)據(jù)不實(shí)時(shí)更新)

    這篇文章主要介紹了解決vue數(shù)據(jù)不實(shí)時(shí)更新的問題(數(shù)據(jù)更改了,但數(shù)據(jù)不實(shí)時(shí)更新),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-10-10
  • vue+echarts定時(shí)重新繪制以達(dá)到刷新的動(dòng)效問題

    vue+echarts定時(shí)重新繪制以達(dá)到刷新的動(dòng)效問題

    這篇文章主要介紹了vue+echarts定時(shí)重新繪制以達(dá)到刷新的動(dòng)效問題,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-06-06
  • Vuex的actions屬性的具體使用

    Vuex的actions屬性的具體使用

    這篇文章主要介紹了Vuex的actions屬性的具體使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • Vue3 Element Plus表格默認(rèn)顯示一行實(shí)例

    Vue3 Element Plus表格默認(rèn)顯示一行實(shí)例

    這篇文章主要介紹了Vue3 Element Plus表格默認(rèn)顯示一行實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2025-07-07

最新評論

启东市| 白银市| 睢宁县| 玛沁县| 芮城县| 新乡县| 平邑县| 五华县| 上虞市| 昌平区| 海安县| 互助| 武隆县| 饶河县| 获嘉县| 永德县| 嘉义市| 桑日县| 栖霞市| 策勒县| 武宁县| 平陆县| 禄丰县| 汽车| 平罗县| 合川市| 郓城县| 都兰县| 古浪县| 贵港市| 巴彦县| 新安县| 江孜县| 卫辉市| 偃师市| 陕西省| 丹江口市| 巨鹿县| 荔波县| 扬州市| 长治县|