它提供了类,并自动将这些类应用于CSS过渡和动画。
它可以集成第三方CSS动画库,例如Animate.css。
它可以使用JavaScript在过渡挂钩期间直接操作DOM。
它可以集成第三方JavaScript动画库,例如Velocity.js。
<transition name = "name_of_the_transition">
<div></div>
</transition>
<html>
<head>
<title>Vue.js Transition</title>
<link rel="stylesheet" href="index.css">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<style>
.fade-enter-active, .fade-leave-active {
transition: opacity 3s
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
opacity: 0
}
</style>
<div id = "databinding">
<p> Click at the below button to see transition effect.</p>
<button v-on:click = "show = !show">Click Here</button>
<transition name = "fade">
<p v-show = "show" v-bind:style = "styleobj">This is a Fade Transition Example</p>
</transition>
</div>
</script>
<script src="index.js"></script>
</body>
</html>
var vm = new Vue({
el: '#databinding',
data: {
show:true,
styleobj :{
fontSize:'30px',
color:'red'
}
},
methods : {
}
})
html, body {
margin: 5px;
padding: 0;
}
<transition name = "fade">
<p v-show = "show" v-bind:style = "styleobj">This is a Fade Transition Example</p>
</transition>
<html>
<head>
<title>Vue.js Transition</title>
<link rel="stylesheet" href="index.css">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<style>
.shiftx-enter-active, .shiftx-leave-active {
transition: all 2s ease-in-out;
}
.shiftx-enter, .shiftx-leave-to /* .fade-leave-active below version 2.1.8 */ {
transform : translateX(100px);
}
</style>
<div id = "databinding">
<p> Click at the below button to see transition effect.</p>
<button v-on:click = "show = !show">Click Here</button>
<transition name = "shiftx">
<p v-show = "show">
<img src = "https://www.flowerpower.com.au/media/catalog/product/image/287189f77f/love-you-rose.jpg" style = "width:100px;height:100px;" />
</p>
</transition>
</div>
</script>
<script src="index.js"></script>
</body>
</html>
var vm = new Vue({
el: '#databinding',
data: {
show:true
},
methods : {
}
})