学到案例部分的时候,尝试使用transition,移除动画没效果
来源:5-1 Vue动画 - Vue中CSS动画原理
迷失的小麦
2020-05-02
<template>
<transition name="city">
<div v-show="isShow">
<city-header></city-header>
<city-search></city-search>
<city-list></city-list>
<city-alphabet></city-alphabet>
</div>
</transition>
</template>
<script>
import CityHeader from './components/header';
import CitySearch from './components/search';
import CityList from './components/list';
import CityAlphabet from './components/alphabet';
export default {
name:'City',
components: {
CityHeader,
CitySearch,
CityList,
CityAlphabet
},
data(){
return{
isShow:false
};
},
mounted () {
this.isShow=true;
}
}
</script>
<style scoped>
.city-enter-active,
.city-leave-active {
transition: all 0.3s;
}
.city-enter,
.city-leave-to {
transform: translate3d(100%, 0, 0);
}
.city-enter-to,
.city-leave{
transform: translate3d(0, 0, 0);
}
</style>
按理说移出动画的时候,transition是组件根节点,符合条件,为什么会没有效果
写回答
1回答
-
Dell
2020-05-03
先跑一下我的代码,也不行吗?
012020-05-04
相似问题