使用vue2.0 transition怎麼完成滑鼠移上去,從螢?zāi)煌鈧?cè)滑出二維碼,離開二維碼滑出螢?zāi)坏男Ч?/p>
光陰似箭催人老,日月如移越少年。
vue 的transition組件會(huì)對(duì)組件內(nèi)的元素進(jìn)行 v-show v-if來進(jìn)行判斷執(zhí)行進(jìn)入動(dòng)畫,離開動(dòng)畫,所以寫好對(duì)應(yīng)的動(dòng)畫後,滑鼠移入顯示,離開隱藏即可
html
<p id="app">
<p id=ad-box @mouseenter='show =true' @mouseleave='show = false'>
我是放廣告的父盒子
<transition name='fade'>
<p id=ad v-show='show'>我是廣告</p>
</transition>
</p>
</p>
css
html, body, #app {
width: 100%;
height: 100%;
}
#ad-box {
width: 200px;
height: 200px;
position: fixed;
right: 0;
bottom: 50%;
background: #cccccc;
}
#ad {
width: 100%;
height: 100%;
background: gray;
}
.fade-enter-active, .fade-leave-active {
transition: opacity .5s
}
.fade-enter, .fade-leave-active {
opacity: 0
}
要是想從螢?zāi)煌饣M(jìn)來就換一下css樣式就好了,大概就這麼寫