html部分
1.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="example-2">
<button @click="show = !show">Toggle show</button>
<transition name="bounce">
<p v-if="show">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris facilisis enim libero, at lacinia diam fermentum id. Pellentesque habitant morbi tristique senectus et netus.</p>
</transition>
</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="../js/css-animation.js"></script>
<link href="../css/css-animation.css" rel="stylesheet">
</body>
</html>
2.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="example-1">
<button @click="show = !show">
Toggle render
</button>
<transition name="slide-fade">
<p v-if="show">hello</p>
</transition>
</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="../js/css-transition.js"></script>
<link href="../css/css-transition" rel="stylesheet">
</body>
</html>
3.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<div v-bind:style="{ color: activeColor, fontSize: fontSize + 'px',background:'red' }">内联样式</div>
</div>
</body>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="../js/style-one.js"></script>
</html>
4.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<div v-bind:style="[baseStyles, overridingStyles]">多样式绑定</div>
</div>
</body>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="../js/style-three.js"></script>
</html>
5.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<div v-bind:style="styleObject">绑定样式对象</div>
</div>
</body>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="../js/style-two.js"></script>
</html>
6.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="demo">
<button v-on:click="show = !show">
Toggle
</button>
<transition name="fade">
<p v-if="show">hello</p>
</transition>
</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="../js/transition.js"></script>
<link href="../css/transition.css" rel="stylesheet">
</body>
</html>
CSS部分
1.
.bounce-enter-active {
animation: bounce-in .5s;
}
.bounce-leave-active {
animation: bounce-in .5s reverse;
}
@keyframes bounce-in {
0% {
transform: scale(0);
}
50% {
transform: scale(1.5);
}
100% {
transform: scale(1);
}
}
2.
/* 可以设置不同的进入和离开动画 */
/* 设置持续时间和动画函数 */
.slide-fade-enter-active {
transition: all .3s ease;
}
.slide-fade-leave-active {
transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for below version 2.1.8 */ {
transform: translateX(10px);
opacity: 0;
}
3.
.fade-enter-active, .fade-leave-active {
transition: opacity .5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
opacity: 0;
}
js部分
1.
new Vue({
el: '#example-2',
data: {
show: true
}
})
2.
new Vue({
el: '#example-1',
data: {
show: true
}
})
3.
new Vue({
el: '#app',
data: {
activeColor: 'green',
fontSize: 30
}
})
4.
new Vue({
el: '#app',
data: {
baseStyles: {
color: 'green',
fontSize: '30px',
background:'red'
},
overridingStyles: {
'font-weight': 'bold'
}
}
})
5.
new Vue({
el: '#app',
data: {
styleObject: {
color: 'green',
fontSize: '30px',
background:'red'
}
}
})
6.
new Vue({
el: '#demo',
data: {
show: true
}
})