{"id":185710,"date":"2023-06-07T22:20:24","date_gmt":"2023-06-07T14:20:24","guid":{"rendered":"http:\/\/www.idc.net\/help\/185710\/"},"modified":"2023-06-07T22:20:24","modified_gmt":"2023-06-07T14:20:24","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91%e5%b0%8f%e7%a8%8b%e5%ba%8f%e6%95%99%e7%a8%8b%ef%bc%9a%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f-%e7%ae%80%e6%98%93%e5%8f%8c%e5%90%91%e7%bb%91%e5%ae%9a","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/185710\/","title":{"rendered":"\u540e\u6d6a\u4e91\u5c0f\u7a0b\u5e8f\u6559\u7a0b\uff1a\u5fae\u4fe1\u5c0f\u7a0b\u5e8f \u7b80\u6613\u53cc\u5411\u7ed1\u5b9a"},"content":{"rendered":"<blockquote><p>\n  \u57fa\u7840\u5e93 2.9.3 \u5f00\u59cb\u652f\u6301\uff0c\u4f4e\u7248\u672c\u9700\u505a \u517c\u5bb9\u5904\u7406\u3002\n<\/p><\/blockquote>\n<h2>\u53cc\u5411\u7ed1\u5b9a\u8bed\u6cd5<\/h2>\n<p>\u5728 WXML \u4e2d\uff0c\u666e\u901a\u7684\u5c5e\u6027\u7684\u7ed1\u5b9a\u662f\u5355\u5411\u7684\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>&lt;input value=\"{{value}}\" \/&gt;\n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528&nbsp;\u200b<code>this.setData({ value: 'leaf' })<\/code>\u200b&nbsp;\u6765\u66f4\u65b0&nbsp;\u200b<code>value<\/code>\u200b&nbsp;\uff0c\u200b<code>this.data.value<\/code>\u200b&nbsp;\u548c\u8f93\u5165\u6846\u7684\u4e2d\u663e\u793a\u7684\u503c\u90fd\u4f1a\u88ab\u66f4\u65b0\u4e3a&nbsp;leaf&nbsp;\uff1b\u4f46\u5982\u679c\u7528\u6237\u4fee\u6539\u4e86\u8f93\u5165\u6846\u91cc\u7684\u503c\uff0c\u5374\u4e0d\u4f1a\u540c\u65f6\u6539\u53d8&nbsp;\u200b<code>this.data.value<\/code>\u200b&nbsp;\u3002<\/p>\n<p>\u5982\u679c\u9700\u8981\u5728\u7528\u6237\u8f93\u5165\u7684\u540c\u65f6\u6539\u53d8&nbsp;\u200b<code>this.data.value<\/code>\u200b&nbsp;\uff0c\u9700\u8981\u501f\u52a9\u7b80\u6613\u53cc\u5411\u7ed1\u5b9a\u673a\u5236\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u5728\u5bf9\u5e94\u9879\u76ee\u4e4b\u524d\u52a0\u5165&nbsp;\u200b<code>model<\/code>\u200b:&nbsp;\u524d\u7f00\uff1a<\/p>\n<pre><code>&lt;input model:value=\"{{value}}\" \/&gt;\n<\/code><\/pre>\n<p>\u8fd9\u6837\uff0c\u5982\u679c\u8f93\u5165\u6846\u7684\u503c\u88ab\u6539\u53d8\u4e86\uff0c&nbsp;\u200b<code>this.data.value<\/code>\u200b&nbsp;\u4e5f\u4f1a\u540c\u65f6\u6539\u53d8\u3002\u540c\u65f6\uff0c WXML \u4e2d\u6240\u6709\u7ed1\u5b9a\u4e86&nbsp;\u200b<code>value<\/code>\u200b&nbsp;\u7684\u4f4d\u7f6e\u4e5f\u4f1a\u88ab\u4e00\u540c\u66f4\u65b0\uff0c&nbsp;\u6570\u636e\u76d1\u542c\u5668&nbsp;\u4e5f\u4f1a\u88ab\u6b63\u5e38\u89e6\u53d1\u3002<\/p>\n<p>\u7528\u4e8e\u53cc\u5411\u7ed1\u5b9a\u7684\u8868\u8fbe\u5f0f\u6709\u5982\u4e0b\u9650\u5236\uff1a<\/p>\n<ol>\n<li>\u53ea\u80fd\u662f\u4e00\u4e2a\u5355\u4e00\u5b57\u6bb5\u7684\u7ed1\u5b9a\uff0c\u5982<\/li>\n<pre><code>&lt;input model:value=\"\u503c\u4e3a {{value}}\" \/&gt;\n&lt;input model:value=\"{{ a + b }}\" \/&gt;\n<\/code><\/pre>\n<p>\u90fd\u662f\u975e\u6cd5\u7684\uff1b<\/p>\n<li>\n<p>\u76ee\u524d\uff0c\u5c1a\u4e0d\u80fd data \u8def\u5f84\uff0c\u5982<\/p>\n<pre><code>&lt;input model:value=\"{{ a.b }}\" \/&gt;\n<\/code><\/pre>\n<p>\u8fd9\u6837\u7684\u8868\u8fbe\u5f0f\u76ee\u524d\u6682\u4e0d\u652f\u6301\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>\u5728\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u4e2d\u4f20\u9012\u53cc\u5411\u7ed1\u5b9a<\/h2>\n<p>\u53cc\u5411\u7ed1\u5b9a\u540c\u6837\u53ef\u4ee5\u4f7f\u7528\u5728\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u4e0a\u3002\u5982\u4e0b\u7684\u81ea\u5b9a\u4e49\u7ec4\u4ef6\uff1a<\/p>\n<pre><code>\/\/ custom-component.js\nComponent({\n  properties: {\n    myValue: String\n  }\n})\n<\/code><\/pre>\n<pre><code>&lt;!-- custom-component.wxml --&gt;\n&lt;input model:value=\"{{myValue}}\" \/&gt;\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5c06\u81ea\u8eab\u7684&nbsp;\u200b<code>myValue<\/code>\u200b&nbsp;\u5c5e\u6027\u53cc\u5411\u7ed1\u5b9a\u5230\u4e86\u7ec4\u4ef6\u5185\u8f93\u5165\u6846\u7684&nbsp;\u200b<code>value<\/code>\u200b&nbsp;\u5c5e\u6027\u4e0a\u3002\u8fd9\u6837\uff0c\u5982\u679c\u9875\u9762\u8fd9\u6837\u4f7f\u7528\u8fd9\u4e2a\u7ec4\u4ef6\uff1a<\/p>\n<pre><code>&lt;custom-component model:my-value=\"{{pageValue}}\" \/&gt;\n<\/code><\/pre>\n<p>\u5f53\u8f93\u5165\u6846\u7684\u503c\u53d8\u66f4\u65f6\uff0c\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7684&nbsp;\u200b<code>myValue<\/code>\u200b&nbsp;\u5c5e\u6027\u4f1a\u540c\u65f6\u53d8\u66f4\uff0c\u8fd9\u6837\uff0c\u9875\u9762\u7684&nbsp;\u200b<code>this.data.pageValue<\/code>\u200b&nbsp;\u4e5f\u4f1a\u540c\u65f6\u53d8\u66f4\uff0c\u9875\u9762 WXML \u4e2d\u6240\u6709\u7ed1\u5b9a\u4e86&nbsp;\u200b<code>pageValue<\/code>\u200b&nbsp;\u7684\u4f4d\u7f6e\u4e5f\u4f1a\u88ab\u4e00\u540c\u66f4\u65b0\u3002<\/p>\n<h2>\u5728\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u4e2d\u89e6\u53d1\u53cc\u5411\u7ed1\u5b9a\u66f4\u65b0<\/h2>\n<p>\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u8fd8\u53ef\u4ee5\u81ea\u5df1\u89e6\u53d1\u53cc\u5411\u7ed1\u5b9a\u66f4\u65b0\uff0c\u505a\u6cd5\u5c31\u662f\uff1a\u4f7f\u7528 setData \u8bbe\u7f6e\u81ea\u8eab\u7684\u5c5e\u6027\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>\/\/ custom-component.js\nComponent({\n  properties: {\n    myValue: String\n  },\n  methods: {\n    update: function() {\n      \/\/ \u66f4\u65b0 myValue\n      this.setData({\n        myValue: 'leaf'\n      })\n    }\n  }\n})\n<\/code><\/pre>\n<p>\u5982\u679c\u9875\u9762\u8fd9\u6837\u4f7f\u7528\u8fd9\u4e2a\u7ec4\u4ef6\uff1a<\/p>\n<pre><code>&lt;custom-component model:my-value=\"{{pageValue}}\" \/&gt;\n<\/code><\/pre>\n<p>\u5f53\u7ec4\u4ef6\u4f7f\u7528&nbsp;\u200b<code>setData<\/code>\u200b&nbsp;\u66f4\u65b0&nbsp;\u200b<code>myValue<\/code>\u200b&nbsp;\u65f6\uff0c\u9875\u9762\u7684&nbsp;\u200b<code>this.data.pageValue<\/code>\u200b&nbsp;\u4e5f\u4f1a\u540c\u65f6\u53d8\u66f4\uff0c\u9875\u9762 WXML \u4e2d\u6240\u6709\u7ed1\u5b9a\u4e86&nbsp;\u200b<code>pageValue<\/code>\u200b&nbsp;\u7684\u4f4d\u7f6e\u4e5f\u4f1a\u88ab\u4e00\u540c\u66f4\u65b0\u3002<\/p>\n<p> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u7840\u5e93 2.9.3 \u5f00\u59cb\u652f\u6301\uff0c\u4f4e\u7248\u672c\u9700\u505a \u517c\u5bb9\u5904\u7406\u3002 \u53cc\u5411\u7ed1\u5b9a\u8bed\u6cd5 \u5728 WXML \u4e2d\uff0c\u666e\u901a\u7684\u5c5e\u6027\u7684\u7ed1\u5b9a\u662f\u5355\u5411\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182398],"tags":[],"class_list":["post-185710","post","type-post","status-publish","format-standard","hentry","category-mini-program"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/185710","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=185710"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/185710\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=185710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=185710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=185710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}