Vue.js开发代码
2018-09-13 本文已影响0人
AFinalStone
index.html
<html>
<head>
<link rel="stylesheet" href="index.css">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app01">
{{ message }}
<p>
{{ value }}</p>
</div>
<div id="app02">
<span v-if="seen">Now you see me</span>
</div>
<div id="app03">
<button v-on:click="show = !show">
Toggle
</button>
<transition name="fade">
<p v-if="show">hello</p>
</transition>
</div>
<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="index.js"></script>
</body>
</html>
index.js
var app01 = new Vue({
el: '#app01',
data: {
message: 'Hello Vue!',
value:'你好'
}
});
var app02 = new Vue({
el: '#app02',
data: {
seen: false
}
})
var app03 =new Vue({
el: '#app03',
data: {
show: true
}
})
var app04 =new Vue({
el: '#app04',
data: {
show: true
}
})
index.css
html, body {
margin: 5px;
padding: 0;
}
/* 过渡动画 */
.fade-enter-active, .fade-leave-active {
transition: opacity .5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
opacity: 0;
}
/* 动画 */
.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);
}
}