<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>vue中的css动画原理</title>
<script src='./vue.js'></script>
<style>
.v-enter,.v-leave-to{
opacity: 0;
},
.v-enter-active,.v-leave-active{
transition: opacity 5s;
}
</style>
</head>
<body>
<div id='app'>
<transition >
<div v-if="show">Hello world</div>
</transition>
<button @click="handleClick">切换</button>
</div>
</body>
<script>
var vm = new Vue({
el:'#app',
data:{
show:true
},
methods:{
handleClick:function(){
this.show = !this.show;
}
}
})
</script>
</html>
老师,帮忙看看,按照您那样写,没有动画效果是什么原因?
课程紧跟Vue3版本迭代,企业主流版本Vue2+Vue3全掌握
了解课程