{"id":981,"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 \u8fc7\u6e21","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/981.html","title":{"rendered":"Vue.js \u8fc7\u6e21"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

Vue.js \u8fc7\u6e21<\/h1>\n<\/p><\/div>\n
\n Vue.js\u63d0\u4f9b\u4e86\u51e0\u79cd\u5728DOM\u4e2d\u63d2\u5165\uff0c\u66f4\u65b0\u6216\u5220\u9664\u9879\u76ee\u65f6\u5c06\u8fc7\u6e21\u548c\u52a8\u753b\u6548\u679c\u5e94\u7528\u4e8e\u5e94\u7528\u7a0b\u5e8f\u7684\u65b9\u6cd5\u3002\u8fd9\u4e9b\u8fc7\u6e21\u548c\u52a8\u753b\u6548\u679c\u7528\u4e8e\u4f7f\u5e94\u7528\u7a0b\u5e8f\u5bf9\u7528\u6237\u5177\u6709\u5438\u5f15\u529b\u548c\u4ea4\u4e92\u6027\u3002\n <\/div>\n
\n \u5b83\u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5de5\u5177\u6765\u6267\u884c\u4ee5\u4e0b\u4efb\u52a1:\n <\/div>\n

\u5b83\u63d0\u4f9b\u4e86\u7c7b\uff0c\u5e76\u81ea\u52a8\u5c06\u8fd9\u4e9b\u7c7b\u5e94\u7528\u4e8eCSS\u8fc7\u6e21\u548c\u52a8\u753b\u3002<\/span>
\n \u5b83\u53ef\u4ee5\u96c6\u6210\u7b2c\u4e09\u65b9CSS\u52a8\u753b\u5e93\uff0c\u4f8b\u5982Animate.css\u3002<\/span>
\n \u5b83\u53ef\u4ee5\u4f7f\u7528JavaScript\u5728\u8fc7\u6e21\u6302\u94a9\u671f\u95f4\u76f4\u63a5\u64cd\u4f5cDOM\u3002<\/span>
\n \u5b83\u53ef\u4ee5\u96c6\u6210\u7b2c\u4e09\u65b9JavaScript\u52a8\u753b\u5e93\uff0c\u4f8b\u5982Velocity.js\u3002<\/span> <\/p>\n

Vue.js\u8fc7\u6e21<\/h3>\n
\n \u5f53\u60a8\u4eceDOM\u4e2d\u63d2\u5165\uff0c\u66f4\u65b0\u6216\u5220\u9664\u9879\u76ee\u65f6\uff0c\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5c06\u8fc7\u6e21\u5e94\u7528\u4e8eHTML\u5143\u7d20\u3002Vue.js\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5185\u7f6e\u7684\u8f6c\u6362\u5305\u88c5\u5668\u7ec4\u4ef6\uff0c\u60a8\u5728\u8f93\u5165\/\u4fdd\u7559\u4efb\u4f55\u5143\u7d20\u6216\u7ec4\u4ef6\u7684\u8f6c\u6362\u65f6\u5fc5\u987b\u4f7f\u7528\u8be5\u7ec4\u4ef6\u3002\u8bf7\u53c2\u89c1\u8fc7\u6e21\u6548\u679c\u7684\u8bed\u6cd5\u3002\n <\/div>\n
\n \u8bed\u6cd5: <\/strong>\n <\/div>\n
\n
 <transition name = \"name_of_the_transition\">
   <div><\/span><\/div><\/span>
<\/transition>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8ba9\u6211\u4eec\u770b\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u4ee5\u4e86\u89e3\u8fc7\u6e21\u6548\u679c\u7684\u6982\u5ff5\u548c\u4f5c\u7528\u3002\n <\/div>\n

Vue.js\u6de1\u5165\u8fc7\u6e21<\/h3>\n
\n \u793a\u4f8b1 <\/strong>\n <\/div>\n
\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Transition<\/title><\/span>
      <link rel=\"stylesheet\" href=\"index.css\">
        <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
    <\/head><\/span>
    <body><\/span>
     <style><\/span>
         .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><\/span>
      <div id = \"databinding\">
          <p><\/span> Click at the below button to see transition effect.<\/p><\/span>
         <button v-on:click = \"show = !show\">Click Here<\/button><\/span>
         <transition name = \"fade\">
            <p v-show = \"show\" v-bind:style = \"styleobj\">This is a Fade Transition Example<\/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: '#databinding',
            data: {
               show:true,
               styleobj :{
                  fontSize:'30px',
                  color:'red'
               }
            },
            methods : {
            }
         })
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8ba9\u6211\u4eec\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684
\n CSS \u6587\u4ef6\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

Vue.js \u8fc7\u6e21_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c1\u5f20 <\/p>\n

\n \u5355\u51fb\u8be5\u6309\u94ae\u65f6\uff0c\u6587\u672c\u5c06\u57283\u79d2\u949f\u5185\u6d88\u200b\u200b\u5931\u3002\u53c2\u89c1\u4e0b\u56fe:\n <\/div>\n

Vue.js \u8fc7\u6e21_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c2\u5f20 <\/p>\n

\u793a\u4f8b\u8bf4\u660e<\/h3>\n
\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a\"Click Here\"\u7684\u6309\u94ae\uff0c\u53ef\u4ee5\u5c06show\u53d8\u91cf\u7684\u503c\u4ecetrue\u66f4\u6539\u4e3afalse\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002\u6211\u4eec\u5728p\u6807\u7b7e\u4e2d\u7f16\u5199\u4e86v-show\u6307\u4ee4\uff0c\u8be5\u6307\u4ee4\u4ec5\u5728\u53d8\u91cf\u4e3atrue\u65f6\u663e\u793a\u6587\u672c\u5143\u7d20\u3002 p\u6807\u7b7e\u4e0etransition\u5143\u7d20\u5305\u88c5\u5728\u4e00\u8d77\uff0c\u5982\u4e0b\u6240\u793a:\n <\/div>\n
\n
 <transition name = \"fade\">
   <p v-show = \"show\" v-bind:style = \"styleobj\">This is a Fade Transition Example<\/p><\/span>
<\/transition>
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8fd9\u662f
\n \u6e10\u53d8\u8fc7\u6e21<\/strong>\u7684\u793a\u4f8b\u3002\u4ee5\u4e0b\u662f\u8fc7\u6e21\u4e2d\u4f7f\u7528\u7684\u4e00\u4e9b\u6807\u51c6\u7c7b\u7684\u5217\u8868:\n <\/div>\n
\n v-enter: <\/strong>: \u6b64\u8fc7\u6e21\u7c7b\u5728\u5143\u7d20\u88ab\u66f4\u65b0\u6216\u6dfb\u52a0\u5230HTML\u5143\u7d20\u4e4b\u524d\u9996\u5148\u88ab\u8c03\u7528\u3002\n <\/div>\n
\n v-enter-active: <\/strong>\u3002\u6b64\u8fc7\u6e21\u7c7b\u7528\u4e8e\u5b9a\u4e49\u8fdb\u5165\u8fc7\u6e21\u9636\u6bb5\u7684\u5ef6\u8fdf\uff0c\u6301\u7eed\u65f6\u95f4\u548c\u7f13\u52a8\u66f2\u7ebf\u3002\u6b64\u7c7b\u6307\u5b9a\u4e86\u6574\u4e2a\u9636\u6bb5\u7684\u6d3b\u52a8\u72b6\u6001\uff0c\u5e76\u4e14\u5728\u6574\u4e2a\u8fdb\u5165\u9636\u6bb5\u90fd\u59cb\u7ec8\u53ef\u7528\u3002\n <\/div>\n
\n v-leave: <\/strong>\n <\/div>\n
\n v-leave-active: <\/strong>: \u6b64\u8fc7\u6e21\u7c7b\u5728\u79bb\u5f00\u9636\u6bb5\u4f7f\u7528\u3002\u8fc7\u6e21\u5b8c\u6210\u540e\uff0c\u6b64\u7c7b\u5c06\u81ea\u52a8\u5220\u9664\u3002\u6b64\u7c7b\u6307\u5b9a\u79bb\u5f00\u9636\u6bb5\u7684\u5ef6\u8fdf\uff0c\u6301\u7eed\u65f6\u95f4\u548c\u7f13\u52a8\u66f2\u7ebf\u3002\n <\/div>\n
\n \u6bcf\u4e2a\u8fc7\u6e21\u7c7b\u90fd\u5c06\u4ee5\u8fc7\u6e21\u540d\u4f5c\u4e3a\u524d\u7f00\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u6de1\u5165\u6de1\u51fa\u8fc7\u6e21\uff0c\u8fd9\u4e9b\u7c7b\u7684\u540d\u79f0\u5206\u522b\u662f.fade_enter\uff0c.fade_enter_active\uff0c.fade_leave\uff0c.fade_leave_active\u3002\n <\/div>\n
\n \u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u540c\u65f6\u5b9a\u4e49\u4e86.fade_enter_active\u548c.fade_leave_active\u7c7b\uff0c\u5e76\u5728\u5f00\u59cb\u548c\u79bb\u5f00\u9636\u6bb5\u5e94\u7528\u8fc7\u6e21\u3002\n <\/div>\n
\n \u5728\u8fd9\u91cc\uff0c\u4e0d\u900f\u660e\u5ea6\u5c5e\u6027\u4f1a\u57283\u79d2\u5185\u53d8\u4e3a0\u3002\n <\/div>\n

Vue.js shiftx\u8fc7\u6e21<\/h3>\n
\n \u518d\u4e3e\u4e00\u4e2a\u4f8b\u5b50\uff0c\u70b9\u51fb\u6309\u94ae\u65f6\u6211\u4eec\u4f7f\u7528\u56fe\u50cf\u5728x\u8f74\u4e0a\u79fb\u52a8\u3002\n <\/div>\n
\n \u8fd9\u91cc\uff0c\u6211\u4eec\u4f7f\u7528
\n shiftx <\/strong>\u8fc7\u6e21\u3002\u6b64transform\u5c5e\u6027\u4f1a\u5c06x\u8f74\u4e0a\u7684\u56fe\u50cf\u79fb\u52a8100px\u3002\u8bf7\u53c2\u89c1\u4ee5\u4e0b\u793a\u4f8b:\n <\/div>\n
\n \u793a\u4f8b2 <\/strong>\n <\/div>\n
\n Index.html\u6587\u4ef6: <\/strong>\n <\/div>\n
\n
 <html><\/span>
   <head><\/span>
      <title><\/span>Vue.js Transition<\/title><\/span>
      <link rel=\"stylesheet\" href=\"index.css\">
        <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/vue\/dist\/vue.js\"><\/script><\/span>
    <\/head><\/span>
    <body><\/span>
     <style><\/span>
         .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><\/span>
      <div id = \"databinding\">
          <p><\/span> Click at the below button to see transition effect.<\/p><\/span>
         <button v-on:click = \"show = !show\">Click Here<\/button><\/span>
         <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><\/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: '#databinding',
            data: {
               show:true
            },
            methods : {
            }
         })
<\/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

Vue.js \u8fc7\u6e21_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c3\u5f20 <\/p>\n

\n \u5355\u51fb\u8be5\u6309\u94ae\u65f6\uff0c\u56fe\u50cf\u5c06\u5411\u53f3\u79fb\u52a8100px\u3002\u8bf7\u53c2\u89c1\u4ee5\u4e0b\u8f93\u51fa:\n <\/div>\n

Vue.js \u8fc7\u6e21_https:\/\/bianchenghao6.com_\u3010vue\u6559\u7a0b\u3011_\u7b2c4\u5f20 <\/p>\n


\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"Vue.js \u8fc7\u6e21zh-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-981","post","type-post","status-publish","format-standard","hentry","category-vuejc"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/981"}],"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=981"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/981\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=981"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=981"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=981"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}