<style>
.box{
width:177px;
height:177px;
transition:all 0.5s
}
.fade-transition{
opacity:1;
background:rgba(7,17,27,0.8);
}
.fade-enter,.fade-leave{
opacity:0;
background:rgba(7,17,27,0);
}
</style>
这种写法在有些版本运行是有效果的,但是在2.8.0版本下却没有效果,点击开启按钮之后只出现一个关闭按钮,现在我们更改一下写法
<template>
<div class="hello">
<button @click="show">开启</button>
<transition>
<div class="box" v-show="this.tf">
<button @click="hide">关闭</button>
</div>
</transition>
</div>
</template>
<script>
export default {
data(){
return{
tf:false
}
},
methods:{
show(){
this.tf=true
},
hide(){
this.tf=false
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
.box{
width:177px;
height:177px;
background:rgba(7,17,27,0.8);
}
.v-enter-active,.v-leave-active{
transition: opacity 0.5s
}
.v-enter,.v-leave-to{
opacity: 0
}
</style>这种写法就有效果了,这是根据官方文档写的,实现之后效果是这样的

四、结语
这是我最近学习遇到的一些小问题,有时候看视频,别人写的代码照着敲,我们敲完之后可能都还运行不了,这时候有可能是版本问题,框架更新了,语法不一样了等等。现在一些框架更新太快了,对我们这些码农来说确实挺考验的。










