{"id":1520,"date":"2023-03-25T14:12:59","date_gmt":"2023-03-25T06:12:59","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1520"},"modified":"2023-04-28T20:18:05","modified_gmt":"2023-04-28T12:18:05","slug":"wechat-mini-program-bindtap-method-parameter","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/wechat-mini-program-bindtap-method-parameter\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8fbindtap\u65b9\u6cd5\u4f20\u53c2"},"content":{"rendered":"<p>\u901a\u8fc7 &quot;data-\u53c2\u6570\u540d&quot; \u7684\u65b9\u5f0f\u7ed1\u5b9a<\/p>\n<h2>WXML<\/h2>\n<p><!-- more --><\/p>\n<pre><code class=\"language-xml\">&lt;view class=&#039;faq&#039;&gt;\n  &lt;view class=&#039;own-data_none&#039; style=&quot;display: {{ askAnswers.length == 0 ? &#039;block&#039; : &#039;none&#039; }}&quot;&gt;{{no_faq_record_msg}}&lt;\/view&gt;\n  &lt;view wx:if=&quot;{{ askAnswers.length &gt; 0 }}&quot;&gt;\n    &lt;view wx:for=&quot;{{askAnswers}}&quot; wx:key=&quot;*this&quot; bindtap=&#039;toggle&#039; data-index=&quot;{{index}}&quot; data-item=&quot;{{item}}&quot;&gt;\n      &lt;view class=&#039;dt&#039;&gt;{{item.ask}}&lt;\/view&gt;\n      &lt;view class=&#039;dd&#039; style=&quot;display: {{ item.showAnswer ? &#039;block&#039; : &#039;none&#039; }}&quot;&gt;{{item.answer}}&lt;\/view&gt;\n    &lt;\/view&gt;\n  &lt;\/view&gt;\n&lt;\/view&gt;<\/code><\/pre>\n<h2>JS<\/h2>\n<pre><code class=\"language-javascript\">toggle(e) {\n  var index = e.currentTarget.dataset.index\n  var item = e.currentTarget.dataset.item\n  \/\/\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7 &quot;data-\u53c2\u6570\u540d&quot; \u7684\u65b9\u5f0f\u7ed1\u5b9a WXML &lt;view class=&#038;#039 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[],"class_list":["post-1520","post","type-post","status-publish","format-standard","hentry","category-wechat-mini-program"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1520","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1520"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1520\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}