{"id":983,"date":"2023-03-23T22:41:43","date_gmt":"2023-03-23T14:41:43","guid":{"rendered":""},"modified":"2023-03-23T22:41:43","modified_gmt":"2023-03-23T14:41:43","slug":"vue.js \u8f6c\u573a\u52a8\u753b","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/983.html","title":{"rendered":"vue.js \u8f6c\u573a\u52a8\u753b"},"content":{"rendered":"
\n
<transition :duration = \"1000\"><\/transition>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u6301\u7eed\u65f6\u95f4\u5c5e\u6027\u4e0e\u8fc7\u6e21\u5143\u7d20\u4e0a\u7684: \u7b26\u53f7\u4e00\u8d77\u4f7f\u7528\uff0c\u5982\u60a8\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\u6240\u89c1\u3002\n <\/div>\n\n \u5982\u679c\u8981\u5206\u522b\u6307\u5b9a\u7528\u4e8e\u8f93\u5165\u548c\u79bb\u5f00\u4e2a\u6848\u7684\u6301\u7eed\u65f6\u95f4\uff0c\u5219\u53ef\u4ee5\u6307\u5b9a\u5982\u4e0b:\n <\/div>\n\n <transition :duration = \"{ enter: 500, leave: 800 }\">...<\/transition>
<\/span><\/code><\/pre>\n<\/p><\/div>\n JavaScript\u94a9\u5b50<\/h3>\n\n \u53ef\u4ee5\u4f7f\u7528
\n JavaScript \u65b9\u6cd5\uff0c\u5c06\u8fc7\u6e21\u7c7b\u79f0\u4e3a\u65b9\u6cd5\u4e00\u4e2a\u3002\u60a8\u53ef\u4ee5\u5728\u5c5e\u6027\u4e2d\u5b9a\u4e49JavaScript\u6302\u94a9\u3002\u8ba9\u6211\u4eec\u770b\u4e00\u4e2a\u4f8b\u5b50\u6765\u5f88\u597d\u5730\u7406\u89e3\u8fd9\u4e2a\u6982\u5ff5:\n <\/div>\n\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n\n <html><\/span>
<head><\/span>
<title><\/span>Vue.js Animation<\/title><\/span>
<link rel=\"stylesheet\" href=\"index.css\">
<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
<script src = \"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/velocity\/1.2.3\/velocity.min.js\"><\/script><\/span>
<\/head><\/span>
<body><\/span>
<div id = \"trans\">
<button @click = \"show = !show\">
<span style = \"font-size:25px;\">Toggle<\/span><\/span>
<\/button><\/span>
<transition v-on:before-enter = \"beforeEnter\"
v-on:enter = \"enter\"
v-on:leave = \"leave\"
v-bind:css = \"false\">
<p v-if = \"show\" style = \"font-size:25px;\">This is an animation Example with velocity<\/p><\/span>
<\/transition>
<\/div><\/span>
<\/script><\/span>
<script src=\"index.js\"><\/script><\/span>
<\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n\n var vm = new Vue({
el: '#trans',
data: {
show: false
},
methods: {
beforeEnter: function (el) {
el.style.opacity = 0
},
enter: function (el, done) {
Velocity(el, { opacity: 1, fontSize: '25px' }, { duration: 1000 })
Velocity(el, { fontSize: '10px' }, { complete: done })
},
leave: function (el, done) {
Velocity(el, { translateX: '15px', rotateZ: '50deg' }, { duration: 1500 })
Velocity(el, { rotateZ: '100deg' }, { loop: 2 })
Velocity(el, {
rotateZ: '45deg',
translateY: '30px',
translateX: '30px',
opacity: 0
}, { complete: done })
}
}
})
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u8ba9\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684CSS\u6587\u4ef6\u6765\u4f7f\u8f93\u51fa\u66f4\u5177\u5438\u5f15\u529b\u3002\n <\/div>\n\n Index.css\u6587\u4ef6: <\/strong>\n <\/div>\n\n html, body {
margin: 5px;
padding: 0;
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n\n \u8f93\u51fa: <\/strong>\n <\/div>\n
<\/p>\n
\n \u5f53\u60a8\u5355\u51fb
\n \"\u5207\u6362\" <\/strong>\u6309\u94ae\u65f6\uff0c\u60a8\u4f1a\u770b\u5230\u8fc7\u6e21\u548c\u52a8\u753b\u3002\u8bf7\u53c2\u89c1\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n 
\n
\n 
\n
\n
<\/p>\n
\u793a\u4f8b\u8bf4\u660e<\/h3>\n\n \u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c\u5219\u5728\u8fc7\u6e21\u5143\u7d20\u4e0a\u4f7f\u7528js\u65b9\u6cd5\u6267\u884c\u52a8\u753b\u3002\u8fc7\u6e21\u65b9\u6cd5\u7684\u5e94\u7528\u5982\u4e0b:\n <\/div>\n\n <transition v-on:before-enter = \"beforeEnter\"
v-on:enter = \"enter\"
v-on:leave = \"leave\"
v-bind:css = \"false\">
<p v-if = \"show\" style = \"font-size:25px;\">Animation Example with velocity<\/p><\/span>
<\/transition>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u5728\u4e8b\u4ef6\u540d\u79f0\u4e4b\u524d\u6dfb\u52a0\u524d\u7f00
\n v-on <\/strong>\u3002\u6211\u4eec\u8fd8\u5728\u8fc7\u6e21
\n v-bind: css =\"false\" <\/strong>\u4e0a\u6dfb\u52a0\u4e86\u4e00\u4e2a\u5c5e\u6027\uff0c\u4ee5\u4fbfVue.js\u5c06\u5176\u7406\u89e3\u4e3aJavaScript\u8fc7\u6e21\u3002\n <\/div>\n\n \u65b9\u6cd5\u5728Vue.js\u5b9e\u4f8b\u5982\u4e0b:\n <\/div>\n\n methods: {
beforeEnter: function (el) {
el.style.opacity = 0
},
enter: function (el, done) {
Velocity(el, { opacity: 1, fontSize: '25px' }, { duration: 1000 })
Velocity(el, { fontSize: '10px' }, { complete: done })
},
leave: function (el, done) {
Velocity(el, { translateX: '15px', rotateZ: '50deg' }, { duration: 1500 })
Velocity(el, { rotateZ: '100deg' }, { loop: 2 })
Velocity(el, {
rotateZ: '45deg',
translateY: '30px',
translateX: '30px',
opacity: 0
}, { complete: done })
}
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u6211\u4eec\u5df2\u5728\u4e0a\u8ff0\u6bcf\u79cd\u65b9\u6cd5\u4e2d\u5e94\u7528\u4e86\u6240\u9700\u7684\u8fc7\u6e21\u3002\u5355\u51fb\u6309\u94ae\u548c\u5b8c\u6210\u52a8\u753b\u540e\uff0c\u5c06\u5e94\u7528\u4e0d\u900f\u660e\u5ea6\u52a8\u753b\u3002\u7b2c\u4e09\u65b9\u5e93\u4e5f\u7528\u4e8e\u52a8\u753b\u3002\n <\/div>\n\u5728\u521d\u59cb\u6e32\u67d3\u65f6\u8fdb\u884c\u8fc7\u6e21<\/h3>\n\n \u5982\u679c\u8981\u5728\u5f00\u59cb\u65f6\u6dfb\u52a0\u52a8\u753b\uff0c\u5219\u5fc5\u987b\u6dfb\u52a0\"\u51fa\u73b0\"\u5c5e\u6027\u5230\u8fc7\u6e21\u5143\u7d20\u3002\u8bf7\u53c2\u9605\u4ee5\u4e0b\u793a\u4f8b\u4ee5\u66f4\u597d\u5730\u7406\u89e3\u5b83:\n <\/div>\n\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n\n <html><\/span>
<head><\/span>
<title><\/span>Vue.js Animation<\/title><\/span>
<link rel=\"stylesheet\" href=\"index.css\">
<link href = \"https:\/\/cdn.jsdelivr.net\/npm\/animate.css@3.5.1\" rel = \"stylesheet\" type = \"text\/css\">
<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
<script src = \"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/velocity\/1.2.3\/velocity.min.js\"><\/script><\/span>
<\/head><\/span>
<body><\/span>
<div id = \"trans_2\" style = \"text-align:center\">
<transition
appear
appear-class = \"custom-appear-class\"
appear-active-class = \"animated bounceIn\">
<h3><\/span>This is BounceIn Animation Example<\/h3><\/span>
<\/transition>
<transition
appear
appear-class = \"custom-appear-class\"
appear-active-class = \"animated swing\">
<h3><\/span>This is Swing Animation Example<\/h3><\/span>
<\/transition>
<transition
appear
appear-class = \"custom-appear-class\"
appear-active-class = \"animated rubberBand\">
<h3><\/span>This is RubberBand Animation Example<\/h3><\/span>
<\/transition>
<\/div><\/span>
<\/script><\/span>
<script src=\"index.js\"><\/script><\/span>
<\/body><\/span>
<\/html><\/span>
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n Index.js\u6587\u4ef6: <\/strong>\n <\/div>\n\n var vm = new Vue({
el: '#trans_2',
data: {
show: true
}
})
<\/span><\/code><\/pre>\n<\/p><\/div>\n\n \u7a0b\u5e8f\u6267\u884c\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n\n \u8f93\u51fa: <\/strong>\n <\/div>\n
<\/p>\n
\n <\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"vue.js \u8f6c\u573a\u52a8\u753bzh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[122],"tags":[],"class_list":["post-983","post","type-post","status-publish","format-standard","hentry","category-vuejc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/983"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=983"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/983\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=983"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=983"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=983"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}