-
Notifications
You must be signed in to change notification settings - Fork 476
/
Copy path08 jsTransitions.html
52 lines (47 loc) · 1.14 KB
/
08 jsTransitions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>08</title>
<script src="vue.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
</head>
<body>
<div id="anim" class="demo">
<p v-show="show" transition="fade">js 过渡</p>
<button @click="show=!show">Toggle</button>
</div>
<script>
Vue.transition('fade', {
css: false,
enter: function(el, done) {
// 元素已被插入 DOM
// 在动画结束后调用 done
$(el)
.css('opacity', 0)
.animate({
opacity: 1
}, 1000, done)
},
enterCancelled: function(el) {
$(el).stop()
},
leave: function(el, done) {
// 与 enter 相同
$(el).animate({
opacity: 0
}, 1000, done)
},
leaveCancelled: function(el) {
$(el).stop()
}
})
new Vue({
el: '#anim',
data: {
show: true
}
})
</script>
</body>
</html>