溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

transition組件如何在vue中使用

發(fā)布時(shí)間:2021-01-29 15:09:27 來源:億速云 閱讀:140 作者:Leah 欄目:開發(fā)技術(shù)

transition組件如何在vue中使用?相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。

transition文檔地址
定義一個(gè)背景彈出層實(shí)現(xiàn)淡入淡出效果

<template>
 <div>
  <button @click="show = !show">
   Toggle
  </button>
  <transition name="fadeBg">
   <div class="bg" v-if="show">hello</div>
  </transition>
 </div>
</template>

<script>
 export default {
  data: () => ({
   show: true
  }),
 };
</script>

<style lang="less" scoped>
 .fadeBg-enter-active,
 .fadeBg-leave-active {
  transition: opacity 0.3s ease;
 }

 .fadeBg-enter,
 .fadeBg-leave-to {
  opacity: 0;
 }

 .bg {
  position: fixed;
  top: 20px;
  left: 0;
  z-index: 105;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
 }
</style>

看完上述內(nèi)容,你們掌握transition組件如何在vue中使用的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI