{"id":201736,"date":"2020-11-25T05:15:08","date_gmt":"2020-11-24T21:15:08","guid":{"rendered":"http:\/\/4563.org\/?p=201736"},"modified":"2020-11-26T00:19:05","modified_gmt":"2020-11-25T16:19:05","slug":"vue-%e9%87%8c-input-%e6%a0%87%e7%ad%be-watch-%e5%92%8c-change-%e9%83%bd%e8%83%bd%e7%9b%91%e5%90%ac%e5%80%bc%e7%9a%84%e5%8f%98%e5%8c%96%ef%bc%8c%e5%93%aa%e4%b8%aa%e6%9b%b4%e5%a5%bd%e5%91%a2%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=201736","title":{"rendered":"Vue \u91cc input \u6807\u7b7e watch \u548c change \u90fd\u80fd\u76d1\u542c\u503c\u7684\u53d8\u5316\uff0c\u54ea\u4e2a\u66f4\u597d\u5462\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Vue \u91cc input \u6807\u7b7e watch \u548c change \u90fd\u80fd\u76d1\u542c\u503c\u7684\u53d8\u5316\uff0c\u54ea\u4e2a\u66f4\u597d\u5462\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chiuGi <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5047\u5982\u6211\u62ff elementui \u4e2d\u6700\u7b80\u5355\u7684 input \u7ec4\u4ef6\u4f5c\u4e3a\u793a\u4f8b<\/p>\n<pre><code>&lt;el-input v-model=\"input\" placeholder=\"\u8bf7\u8f93\u5165\u5185\u5bb9\"&gt;&lt;\/el-input&gt;  &lt;script&gt; export default {   data() {     return {       input: ''     }   } } &lt;\/script&gt; <\/code><\/pre>\n<p>\u6b64\u65f6\u6211\u60f3\u76d1\u542c input \u7684\u503c\uff0cinput \u6807\u7b7e\u7684 change \u65b9\u6cd5\u548c vue \u7684 watch \u90fd\u80fd\u76d1\u542c\u5230\uff0c\u90a3\u90a3\u4e2a\u4f1a\u66f4\u5e38\u7528\u5462\uff1f \u54ea\u4e2a\u4f1a\u6027\u80fd\u66f4\u597d\u634f\uff1f\u6709\u4ec0\u4e48\u68c0\u6d4b\u8fd9\u4e2a\u7684\u65b9\u6cd5\u5417\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>6<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4311591\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : asiasky <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6027\u80fd\u5e94\u8be5\u662f watch \u4f1a\u66f4\u597d\u4e00\u4e0b\u5427\u4e5f\u66f4\u5e38\u7528\u4e00\u4e9b,\u672c\u6765 vue \u5c31\u5e2e\u4f60\u76d1\u542c\u4e86\u6ca1\u5fc5\u8981\u5728\u91cd\u590d\u58f0\u660e,\u611f\u89c9\u6709\u4e9b\u8fc7\u4e8e\u5439\u6bdb\u6c42\u75b5\u4e86,\u5176\u5b9e\u6ca1\u6709\u90a3\u4e48\u660e\u663e\u7684\u6027\u80fd\u4f18\u5316&#8230;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4311592\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : johnkiller <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @change \u662f\u539f\u751f DOM \u7684\u56de\u8c03\u4e8b\u4ef6\uff0cwatch \u662f Vue \u4e2d\u76d1\u542c\u53d8\u91cf\u6539\u53d8\u3002\u4e3b\u8981\u8fd8\u662f\u770b\u4f60\u81ea\u5df1\u7684\u4f7f\u7528\u573a\u666f\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4311593\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zidian <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709\u65f6\u7528\u6cd5\u4e0d\u4e00\u6837\u554a\u3002this.input = xxx \u7684\u65f6\u5019 watch \u4e5f\u4f1a\u88ab\u8c03\u7528\uff0cchange \u53ea\u6709\u8868\u5355\u8f93\u5165\u624d\u88ab\u8c03\u7528\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4311594\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wunonglin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &lt;el-input v-model=&#8221;content&#8221; placeholder=&#8221;\u8bf7\u8f93\u5165\u5185\u5bb9&#8221;&gt;&lt;\/el-input&gt;<\/p>\n<p>export default {<br \/> data() {<br \/> return {<br \/> input: &#8221;<br \/> }<br \/> },<br \/> computed: {<br \/> content: {<br \/> get: function(){<br \/> return this.input<br \/> },<br \/> set: function(value){<br \/> this.input = value<br \/> \/\/ \u60f3\u5e72\u561b\u5c31\u5e72\u561b <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/11\/504J5BO2-104.png\" alt=\"Vue \u91cc input \u6807\u7b7e watch \u548c change \u90fd\u80fd\u76d1\u542c\u503c\u7684\u53d8\u5316\uff0c\u54ea\u4e2a\u66f4\u597d\u5462\uff1f\"> <br \/> }<br \/> }<br \/> }<br \/>}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4311595\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : marcong95 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             v-model \u662f:value \u548c @input \u7684\u8bed\u6cd5\u7cd6\uff0c\u8ddf @change \u597d\u50cf\u5dee\u8ddd\u6709\u70b9\u5927\uff0cchange \u5e94\u8be5\u662f input \u5931\u53bb\u7126\u70b9\u65f6\u503c\u53d1\u751f\u66f4\u6539\u624d\u89e6\u53d1                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4311596\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wunonglin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u590d\u6742\u7684\u8bdd\u8fd8\u662f\u5efa\u8bae watch\uff0c\u6bd5\u7adf\u8fd9\u662f vue \u7684\u65b9\u6cd5\uff0c\u7b80\u5355\u7684\u8bdd\u7528 get\/set \u5c31\u884c\u4e86\uff0c\u8fd9\u662f js \u7684\u65b9\u6cd5                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Vue \u91cc input \u6807\u7b7e wa&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\/201736"}],"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=201736"}],"version-history":[{"count":1,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/201736\/revisions"}],"predecessor-version":[{"id":201738,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/201736\/revisions\/201738"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=201736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=201736"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=201736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}