{"id":125007,"date":"2020-06-14T21:28:58","date_gmt":"2020-06-14T13:28:58","guid":{"rendered":"http:\/\/4563.org\/?p=125007"},"modified":"2020-06-14T21:28:58","modified_gmt":"2020-06-14T13:28:58","slug":"vue-%e7%88%b6%e7%bb%84%e4%bb%b6%e5%8f%af%e4%bb%a5%e9%80%9a%e8%bf%87-ref-%e4%bf%ae%e6%94%b9%e5%ad%90%e7%bb%84%e4%bb%b6%e7%9a%84%e5%80%bc%ef%bc%8c%e9%82%a3%e4%b9%88%e6%88%91%e4%bb%ac%e8%bf%98%e8%a6%81","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=125007","title":{"rendered":"Vue \u7236\u7ec4\u4ef6\u53ef\u4ee5\u901a\u8fc7 ref \u4fee\u6539\u5b50\u7ec4\u4ef6\u7684\u503c\uff0c\u90a3\u4e48\u6211\u4eec\u8fd8\u8981\u4e0d\u8981\u901a\u8fc7 prop \u53bb\u4f20\u503c\u5462\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Vue \u7236\u7ec4\u4ef6\u53ef\u4ee5\u901a\u8fc7 ref \u4fee\u6539\u5b50\u7ec4\u4ef6\u7684\u503c\uff0c\u90a3\u4e48\u6211\u4eec\u8fd8\u8981\u4e0d\u8981\u901a\u8fc7 prop \u53bb\u4f20\u503c\u5462\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JaaaaackZheng <\/span>  <span><i><\/i> 11<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u60f3\u8bf7\u6559\u5404\u4f4d\u5927\u4f6c\u5982\u6807\u9898\u6240\u8ff0\u7684\u95ee\u9898\uff0c\u5e76\u4e14\u54a8\u8be2\u4e00\u4e0b\uff1a 1.\u5982\u679c\u66f4\u597d\u7684\u5bf9\u524d\u7aef Vue \u4ee3\u7801\u5212\u5206\u6a21\u5757\uff0c\u6709\u4ec0\u4e48\u8bc0\u7a8d\u5417 2.\u7ec4\u4ef6\u95f4\u4f20\u503c\u7684\u8f83\u597d\u7684\u89e3\u51b3\u65b9\u6848\uff1a\u7236\u7ec4\u4ef6\u5411\u5b50\u7ec4\u4ef6\u53ef\u901a\u8fc7 ref \u4e0e prop\uff0c\u611f\u89c9\u64cd\u4f5c ref \u6bd4\u7528 prop \u4f20\u503c\u66f4\u65b9\u4fbf\uff0c\u6709\u4ec0\u4e48\u5f0a\u7aef\u5417\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>11<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2081304\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ochatokori <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             ref \u662f\u7236\u7ec4\u4ef6\u5355\u5411\u4fee\u6539\u5b50\u7ec4\u4ef6\u7684\u503c<br \/>\u7528 prop \u7ed1\u5b9a\u53d8\u91cf\u7684\u8bdd\u4efb\u4f55\u4e00\u65b9\u4fee\u6539\u5bf9\u65b9\u90fd\u80fd\u611f\u77e5<\/p>\n<p>\u5982\u679c\u4f60\u53ea\u662f\u5355\u7eaf\u7684\u9700\u8981\u7236\u7ec4\u4ef6\u4fee\u6539\u5b50\u7ec4\u4ef6\u54cd\u5e94\u90a3\u7528 ref \u6ca1\u95ee\u9898\uff0c\u4e0d\u8fc7\u8fd8\u662f\u5efa\u8bae\u4f7f\u7528 prop\uff0c\u56e0\u4e3a\u4ee5\u540e\u770b\u7684\u65f6\u5019\u770b\u4e00\u773c props \u5c31\u80fd\u77e5\u9053\u6709\u4ec0\u4e48\u53c2\u6570\u53ef\u4ee5\u6539\u4e86                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081305\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : crclz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bc0\u7a8d\uff1a\u5c06 Angular \u7684\u98ce\u683c\u8fd0\u7528\u4e8e Vue \u3002<\/p>\n<p>Angular \u538b\u6839\u4e0d\u5141\u8bb8\u6301\u6709\u5b50\u7ec4\u4ef6\u7684\u5f15\u7528\uff08\u5728 Vue \u4e2d\u5bf9\u5e94 vm\uff0cvar vm=new Vue(&#8230;)\uff09\uff0c\u66f4\u522b\u63d0\u8c03\u7528\u5b50\u7ec4\u4ef6\u7684\u65b9\u6cd5\uff08 Vue \u4e2d\u5e94\u8be5\u662f methods \uff09\u548c\u4fee\u6539\u5b50\u7ec4\u4ef6\u7684\u6210\u5458\u503c\uff08\u5728 Vue \u4e2d\u5e94\u8be5\u662f data \uff09\u3002<\/p>\n<p>Angular \u901a\u8fc7 props \u548c Service \u4f20\u503c\uff0c\u90a3\u4e48\u5728 Vue \u91cc\u9762\u5e94\u5f53\u4e5f\u4f7f\u7528 props \u548c\u72b6\u6001\u7ba1\u7406\uff08 vuex \uff09\u4f20\u503c\u3002<\/p>\n<p>\u7136\u540e\uff0c\u4f20\u9012\u53d8\u5316\u3001\u591a\u503c\u9700\u8981\u7528\u5230\u4e00\u4e2a\u7b80\u5355\u4f18\u96c5\u7684\u7c7b\u2014\u2014Observable \uff08 rxjs \uff09\uff0c\u4e5f\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u5355\u72ec\u5f15\u5165 vue \u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081306\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hitaoguo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u901a\u8fc7 ref \u53bb\u6539\u7ec4\u4ef6\u7684\u503c\u611f\u89c9\u5c31\u662f\u5f3a\u884c\u4fee\u6539\u4e86\u3002<\/p>\n<p>\u7ec4\u4ef6\u4e00\u822c\u90fd\u4f1a\u63d0\u4f9b\u4e00\u4e9b\u53c2\u6570\uff0c\u62ff element-ui \u4e3e\u4f8b\uff0cbutton \u7ec4\u4ef6\u6709 type,size \u53c2\u6570\uff0c\u901a\u8fc7 prop \u53bb\u4f20\u5f88\u65b9\u4fbf\u4e5f\u5f88\u76f4\u89c2\uff0c\u800c\u4e14\u662f\u5199\u5728\u6a21\u677f\u91cc\u5c31\u53ef\u4ee5\uff0c\u540e\u9762\u5982\u679c\u52a8\u6001\u4fee\u6539\u7684\u8bdd\uff0c\u7236\u7ec4\u4ef6\u91cc this.btn_type \u4e5f\u6bd4 this.$refs.btn.type \u8981\u65b9\u4fbf\u4e9b\u5427\u3002<\/p>\n<p>\u6211\u4e2a\u4eba\u7528\u5230 ref \u7684\u65f6\u5019\uff0c\u57fa\u672c\u90fd\u662f\u8c03\u7528\u5b50\u7ec4\u4ef6\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u5bf9\u4e86\uff0cprops \u8fd8\u53ef\u4ee5\u505a\u4e00\u4e9b\u7b80\u5355\u7684\u9a8c\u8bc1                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081307\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : tutou <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u89c9\u5f97\u7684\u662f\u89e3\u8026\u7684\u8868\u73b0\u5427\uff01\u5b50\u7ec4\u4ef6\u53ea\u5173\u6ce8 prop\uff0c\u4e0d\u5173\u6ce8\u54ea\u91cc\u6765\u7684\u3002\u5982\u679c\u7236\u7ec4\u4ef6\u76f4\u63a5 ref \u7684\u8bdd\u7136\u540e\u5b50\u7ec4\u4ef6\u5c31\u88ab\u8026\u5408\u4e86\uff0c\u72b6\u6001\u4fee\u6539\u4e5f\u4e0d\u597d\u8ffd\u6eaf\u6765\u6e90\uff0c\u5c31\u8ddf\u5199\u4e00\u8d77\u6ca1\u533a\u522b\u4e86\u3002\u6211\u6709\u65f6\u4e5f\u76f4\u63a5\u7528 ref \u56e0\u4e3a\u6709\u7684 prop \u7236\u7ec4\u4ef6\u662f\u63a5\u53e3\u8fd4\u56de\u7684\uff0c\u5b50\u7ec4\u4ef6\u672a\u80fd\u53ca\u65f6\u66f4\u65b0\u5230\u6700\u65b0\u7684\u72b6\u6001                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081308\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JerryCha <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a props \u5f53\u6210 properties\uff0c\u53ea\u7528\u4e8e\u63cf\u8ff0\u5b50\u7ec4\u4ef6\u7684\u7279\u5f81\uff0c\u8de8\u7ec4\u4ef6\u52a8\u6001\u66f4\u65b0\u6570\u636e\u6211\u7528 vuex \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081309\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : TomatoYuyuko <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0a\u8bf4\u7684\u5bf9\uff0c\u91cd\u70b9\u8fd8\u662f\u89e3\u8026\u7684\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081310\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : DoodleSit <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528\u8fc7\u51fd\u6570\u7ec4\u4ef6\u4f60\u5c31\u61c2\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081311\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : nianyu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u6bcf\u6b21 this.$refs.xxx.xxx = xxx \u4e0d\u5acc\u9ebb\u70e6\u5417                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081312\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : redbuck <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u547d\u4ee4\u5f0f\u7f16\u7a0b\u548c\u58f0\u660e\u5f0f\u7684\u533a\u522b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081313\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : SilentDepth <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6838\u5fc3\u95ee\u9898\u5728\u4e8e\uff0c\u901a\u8fc7 ref \u8bbf\u95ee\u7684\u662f\u5b50\u7ec4\u4ef6\u7684\u72b6\u6001\uff0cprop \u4f20\u9012\u7684\u662f\u7236\u7ec4\u4ef6\u7684\u72b6\u6001\u3002\u90a3\u4e48\u4f60\u8981\u6539\u7684\u72b6\u6001\u662f\u8c01\u7684\u72b6\u6001\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2081314\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JayLin1011 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5efa\u8bae\u4f60\u8be6\u7ec6\u628a Vue \u6587\u6863\u597d\u597d\u901a\u8bfb\u4e00\u904d\uff0c\u4e00\u904d\u5c31\u597d\uff0c\u4f60\u5c31\u80fd\u5f97\u5230\u5f88\u591a\u60f3\u8981\u7684\u7b54\u6848\u3002<br \/>1. \u6700\u81f4\u547d\u7684\u4e00\u70b9\uff0cref \u7684\u6570\u636e\u662f\u975e\u54cd\u5e94\u5f0f\u7684\uff0c\u8fd9\u51b3\u5b9a\u4e86\u4f60\u7684\u6570\u636e\u4f7f\u7528\u4e0d\u7b26\u5408\u9884\u671f\uff0c\u505a\u4e0d\u5230\u6570\u636e\u9a71\u52a8\u89c6\u56fe\uff0c\u4e5f\u5f97\u4e0d\u5230\u6700\u65b0\u6570\u636e\uff1b<br \/>2. \u975e\u53d7\u63a7\u7ec4\u4ef6\u7684\u6570\u636e\u6765\u6e90\u4e0d\u660e\u786e\uff0c\u8fdd\u80cc\u5355\u5411\u6570\u636e\u6d41\u7684\u8bbe\u8ba1\uff1b<br \/>3. ref \u7684\u7c7b\u578b\u6821\u9a8c\u600e\u4e48\u8fdb\u884c\uff0c\u4e5f\u5c31\u662f\u8bf4\u4f60\u5e73\u65f6\u4f7f\u7528 props \u4e5f\u6ca1\u6709\u9a8c\u8bc1\u7c7b\u578b\uff0c\u8fd9\u662f\u4e0d\u597d\u7684\u4e60\u60ef\u54e6\uff1b<br \/>4. ref \u83b7\u53d6\u5143\u7d20\u9700\u8981\u8003\u8651\u65f6\u673a\uff0c\u6bd4\u5982\u53ea\u6709\u5728\u5408\u9002\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50\u624d\u80fd\u4f7f\u7528\uff0c\u90a3\u4e48 props \u9700\u4e0d\u9700\u8981\u5462\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Vue \u7236\u7ec4\u4ef6\u53ef\u4ee5\u901a\u8fc7 ref \u4fee&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\/125007"}],"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=125007"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/125007\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=125007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=125007"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=125007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}