官方文档
<style>
.a {
width: 100px;
height: 100px;
background-color: springgreen;
}
.slide-leave {
height: 100px;
opacity: 1;
background-color: springgreen;
}
.slide-leave-to {
height: 0;
opacity: 0;
background-color: hotpink;
}
.slide-leave-active {
transition: all 5s;
}
.slide-enter {
height: 0;
opacity: 0;
background-color: hotpink;
}
.slide-enter-to {
height: 100px;
opacity: 1;
background-color: springgreen;
}
.slide-enter-active {
transition: all 5s;
}
</style>
<body>
<div id="app">
<!-- 设置进入效果, 要在外层包裹一个 transition -->
<transition name="slide">
<div class="a" v-show="isShow"></div>
</transition>
<button @click="isShow=!isShow">点击切换</button>
</div>
<script>
new Vue({
el: '#app',
data: {
isShow: true,
},
})
</script>
</body>
?
|