{"id":420685,"date":"2021-04-01T16:50:04","date_gmt":"2021-04-01T08:50:04","guid":{"rendered":"http:\/\/4563.org\/?p=420685"},"modified":"2021-04-01T16:50:04","modified_gmt":"2021-04-01T08:50:04","slug":"%e8%af%b7%e9%97%ae-vue-%e4%b8%ad%e7%88%b6%e7%bb%84%e4%bb%b6%e5%8f%af%e4%bb%a5%e5%91%8a%e7%9f%a5%e5%ad%90%e7%bb%84%e4%bb%b6%e5%8f%91%e7%94%9f%e4%ba%86%e4%ba%8b%e4%bb%b6%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=420685","title":{"rendered":"\u8bf7\u95ee vue \u4e2d\u7236\u7ec4\u4ef6\u53ef\u4ee5\u544a\u77e5\u5b50\u7ec4\u4ef6\u53d1\u751f\u4e86\u4e8b\u4ef6\u5417\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u95ee vue \u4e2d\u7236\u7ec4\u4ef6\u53ef\u4ee5\u544a\u77e5\u5b50\u7ec4\u4ef6\u53d1\u751f\u4e86\u4e8b\u4ef6\u5417\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u6211\u9047\u5230\u7684\u60c5\u666f\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p>\u4e00\u4e2a div \u5143\u7d20\uff0c\u5c31\u53eb\u5b83 A \u4e86\u3002\u5b83\u5185\u90e8\u6709\u4e00\u4e2a card \u7ec4\u4ef6\uff08\u5373\u5bf9\u5e94\u4e00\u4e2a\u88ab\u5f15\u8fdb\u6765\u5e76\u58f0\u660e\u5728 components \u91cc\u7684 .vue \u6587\u4ef6\uff09\uff0c\u5728\u9875\u9762\u4e0a\u5927\u6982\u662f\u4e00\u5f20\u5361\u7247\u7684\u6837\u5f0f\u3002<\/p>\n<p>\u9664\u6b64\u4e4b\u5916\uff0c\u5728 A \u4e2d\u8fd8\u6709\u4e00\u4e2a button \u5143\u7d20\uff0c\u5c31\u53eb\u5b83\u6309\u94ae\u4e86\u3002\u4e0a\u9762\u90a3\u4e2a\u5361\u7247\u53ef\u4ee5\u7406\u89e3\u4e3a\u6709\u6b63\u53cd\u4e24\u9762\uff0c\u6309\u94ae\u53ea\u6709\u5728\u5361\u7247\u4e3a\u53cd\u9762\u65f6\u53ef\u7528\uff0c\u6b63\u9762\u65f6\u8981 disable=true \u3002<\/p>\n<p>\u9f20\u6807\u5728\u90a3\u5f20\u5361\u7247\u4e0a\u70b9\u51fb\uff0c\u6b64\u65f6\u5361\u7247\u7ec4\u4ef6\u5185\u90e8\u6709\u4e00\u4e2a isFront \u53d8\u4e3a false\uff0c\u4e8e\u662f\u53cd\u9762\uff0c\u5373 `v-if=!isFront` \u7684\u5185\u5bb9\u51fa\u73b0\uff0c\u6b63\u9762\uff0c\u5373 `v-if=isFront` \u7684\u5185\u5bb9\u6d88\u5931\uff0cA \u4e2d\u7684\u6309\u94ae\u53ef\u7528\u3002\u518d\u5728\u90a3\u5f20\u5361\u7247\u4e0a\u70b9\u51fb\uff0c\u5361\u7247\u7684\u6b63\u9762\u5185\u5bb9\u51fa\u73b0\uff0c\u53cd\u9762\u5185\u5bb9\u6d88\u5931\uff0c\u6309\u94ae\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u4f46\u540c\u65f6\uff0c\u5f53\u6309\u94ae\u53ef\u7528\u65f6\uff0c\u8981\u6c42\u6309\u4e0b\u6309\u94ae\uff0c\u5361\u7247\u7531\u53cd\u9762\u53d8\u4e3a\u6b63\u9762\uff0c\u4e14\u6309\u94ae\u968f\u4e4b\u4e0d\u53ef\u7528\u3002<\/p>\n<p>\u5c31\u662f\u8fd9\u91cc\u8fd9\u4e2a\u6309\u4e0b\u6309\u94ae\u7684\u4e8b\u4ef6\uff0c\u4e0d\u77e5\u9053\u6709\u4ec0\u4e48\u529e\u6cd5\u901a\u77e5\u7ed9\u5b50\u7ec4\u4ef6\u5417\uff1f<\/p>\n<p>\u6211\u73b0\u5728\u7684\u7528\u6cd5\u662f\u7528\u4e00\u4e2a\u6570\u503c\u7c7b\u578b\u7684\u53d8\u91cf buttonClicked \u4f5c\u4e3a props \u4f20\u9012\u5230\u5b50\u7ec4\u4ef6\u5185\u90e8\uff0c\u5b50\u7ec4\u4ef6\u5185\u90e8 watch \u8fd9\u4e2a props\uff0c\u6309\u94ae\u6309\u4e0b\u8fd9\u4e2a buttonClicked \u5c31 ++\uff0c\u4e5f\u76f8\u5f53\u4e8e\u901a\u77e5\u5230\u4e86\u4e8b\u4ef6\u3002\u4f46\u662f\u611f\u89c9\u8fd9\u4e2a\u5b9e\u73b0\u5f88\u4e0d\u4f18\u96c5\uff0c\u4e0d\u77e5\u9053\u6709\u6ca1\u6709\u66f4\u597d\u7684\u529e\u6cd5\u3002<\/p>\n<p>\u8c22\u8c22      <\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5610494\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : codder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7236\u7ec4\u4ef6\u4f20\u503c\u7ed9\u5b50\u7ec4\u4ef6\u7528 props\uff0c\u5b50\u7ec4\u4ef6\u4f20\u503c\u7ed9\u670d\u7ec4\u4ef6\u7528 emit\uff0c\u597d\u597d\u770b\u770b\u5b98\u65b9\u7684\u6587\u6863\u91cc\u9762\u90fd\u6709\u7684\uff01                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5610495\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : murmur <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7236\u7ec4\u4ef6\u4e0d\u662f\u53ef\u4ee5\u76f4\u63a5 ref \u8c03\u7528\u5b50\u7ec4\u4ef6\u7684\u65b9\u6cd5\uff0c\u7528\u5f97\u5230\u4e8b\u4ef6\u4e48                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5610496\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Laz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u591a\u770b\u6587\u6863                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5610497\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : falcon05 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u4e5f\u662f watch props \u3002\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5610498\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : DL9412 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53c2\u8003 vue \u5b98\u7f51\u98ce\u683c\u6307\u5357\uff0chttps:\/\/cn.vuejs.org\/v2\/style-guide\/#\u9690\u6027\u7684\u7236\u5b50\u7ec4\u4ef6\u901a\u4fe1\u8c28\u614e\u4f7f\u7528<\/p>\n<p>\u539f\u6587\uff1a <\/p>\n<p>\u5e94\u8be5\u4f18\u5148\u901a\u8fc7 prop \u548c\u4e8b\u4ef6\u8fdb\u884c\u7236\u5b50\u7ec4\u4ef6\u4e4b\u95f4\u7684\u901a\u4fe1\uff0c\u800c\u4e0d\u662f this.$parent \u6216\u53d8\u66f4 prop \u3002<br \/>\u4e00\u4e2a\u7406\u60f3\u7684 Vue \u5e94\u7528\u662f prop \u5411\u4e0b\u4f20\u9012\uff0c\u4e8b\u4ef6\u5411\u4e0a\u4f20\u9012\u7684\u3002\u9075\u5faa\u8fd9\u4e00\u7ea6\u5b9a\u4f1a\u8ba9\u4f60\u7684\u7ec4\u4ef6\u66f4\u6613\u4e8e\u7406\u89e3\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5610499\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : renmu123 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5728 A \u4e2d\u5b9a\u4e49 isfront \u7136\u540e\u901a\u8fc7 prop \u4f20\u9012\u7ed9 card \u7ec4\u4ef6?                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5610500\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/cn.vuejs.org\/v2\/guide\/components-edge-cases.html#\u8bbf\u95ee\u5b50\u7ec4\u4ef6\u5b9e\u4f8b\u6216\u5b50\u5143\u7d20                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5610501\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Shook <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7ed9\u5361\u7247\u7ed1\u5b9a ref<br \/>&lt;card ref=&#8221;card&#8221; \/&gt;<\/p>\n<p>\u7ed9\u6309\u94ae\u7ed1\u5b9a flip()\u65b9\u6cd5<br \/>&lt;button @click=&#8221;flip&#8221;&gt;Flip&lt;\/button&gt;<\/p>\n<p>\u5728 flip()\u65b9\u6cd5\u4e2d\uff0c\u8c03\u7528 card \u7ec4\u4ef6\u5185\u65b9\u6cd5<br \/>this.$refs.card.onClick();<\/p>\n<p>\u5728 card \u7ec4\u4ef6\u7684 onClick()\u65b9\u6cd5\u4e2d\uff0c\u5207\u6362 isFront<br \/>\u70b9\u51fb card \u7ec4\u4ef6\u65f6\uff0c\u8c03\u7528\u7684\u4e5f\u662f\u8fd9\u4e2a\u65b9\u6cd5<br \/>this.isFront = !this.isFront;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5610502\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : codder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7ed9\u4f60\u5199\u4e86\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u4f60\u81ea\u5df1\u7814\u7a76\u7814\u7a76\u5427\uff01\u84dd\u594f\u57df\u540d \/iFLCmnh4khg \u5bc6\u7801:6fxx                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5610503\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : codder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @codder \u84dd\u594f\u57df\u540d: wws.lanzous.com                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u95ee vue \u4e2d\u7236\u7ec4\u4ef6\u53ef\u4ee5\u544a\u77e5\u5b50\u7ec4&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/420685"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=420685"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/420685\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=420685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=420685"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=420685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}