{"id":31823,"date":"2024-11-25T15:57:25","date_gmt":"2024-11-25T07:57:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31823\/"},"modified":"2024-11-25T15:57:25","modified_gmt":"2024-11-25T07:57:25","slug":"%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e4%b8%adpicker%e7%bb%84%e4%bb%b6%e7%9a%84%e7%ae%80%e5%8d%95%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31823\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2dpicker\u7ec4\u4ef6\u7684\u7b80\u5355\u7528\u6cd5"},"content":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8fpicker\u7ec4\u4ef6\u7b80\u5355\u7528\u6cd5,\u7ed3\u5408\u5b9e\u4f8b\u5f62\u5f0f\u8be6\u7ec6\u5206\u6790\u4e86picker\u7ec4\u4ef6\u7684\u529f\u80fd\u3001\u4f7f\u7528\u65b9\u6cd5\u4e0e\u76f8\u5173\u6ce8\u610f\u4e8b\u9879,\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b<\/p>\n<p>\u672c\u6587\u5b9e\u4f8b\u8bb2\u8ff0\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8fpicker\u7ec4\u4ef6\u7b80\u5355\u7528\u6cd5\u3002\u5206\u4eab\u7ed9\u5927\u5bb6\u4f9b\u5927\u5bb6\u53c2\u8003\uff0c\u5177\u4f53\u5982\u4e0b\uff1a<\/p>\n<p>picker\u6eda\u52a8\u9009\u62e9\u5668\uff0c\u73b0\u652f\u6301\u4e09\u79cd\u9009\u62e9\u5668\uff0c\u901a\u8fc7mode\u6765\u533a\u5206\uff0c\u5206\u522b\u662f\u666e\u901a\u9009\u62e9\u5668\uff08<span style=\"color: #0000ff\">mode=selector<\/span>\uff09\uff0c\u65f6\u95f4\u9009\u62e9\u5668\uff08<span style=\"color: #0000ff\">mode=time<\/span>\uff09\uff0c\u65e5\u671f\u9009\u62e9\u5668\uff08<span style=\"color: #0000ff\">mode=date<\/span>\uff09\uff0c\u9ed8\u8ba4\u662f\u666e\u901a\u9009\u62e9\u5668\u3002<\/p>\n<p>\u5177\u4f53\u529f\u80fd\u8bf4\u660e\u5982\u4e0b\uff1a<\/p>\n<p><strong>\u666e\u901a\u9009\u62e9\u5668\uff1amode=selector<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027\u540d<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>range<\/td>\n<td>Array<\/td>\n<td>[]<\/td>\n<td>mode\u4e3aselector\u65f6\uff0crange\u6709\u6548<\/td>\n<\/tr>\n<tr>\n<td>value<\/td>\n<td>Number<\/td>\n<td>0<\/td>\n<td>mode\u4e3aselector\u65f6\uff0c\u662f\u6570\u5b57\uff0c\u8868\u793a\u9009\u62e9\u4e86range\u4e2d\u7684\u7b2c\u51e0\u4e2a\uff0c\u4ece0\u5f00\u59cb\u3002<\/td>\n<\/tr>\n<tr>\n<td>bindchange<\/td>\n<td>EventHandle<\/td>\n<td>&nbsp;<\/td>\n<td>value\u6539\u53d8\u65f6\u89e6\u53d1change\u4e8b\u4ef6\uff0cevent.detail= { value:value}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u65f6\u95f4\u9009\u62e9\u5668\uff1amode=time<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027\u540d<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>value<\/td>\n<td>String<\/td>\n<td>&nbsp;<\/td>\n<td>\u8868\u793a\u9009\u4e2d\u7684\u65f6\u95f4\uff0c\u683c\u5f0f\u4e3a&#8221;<span style=\"color: #0000ff\">hh:mm<\/span>&#8220;<\/td>\n<\/tr>\n<tr>\n<td>&nbsp;start<\/td>\n<td>String<\/td>\n<td>&nbsp;<\/td>\n<td>\u8868\u793a\u6709\u6548\u65f6\u95f4\u8303\u56f4\u7684\u5f00\u59cb\uff0c\u5b57\u7b26\u4e32\u683c\u5f0f\u4e3a&#8221;<span style=\"color: #0000ff\">hh:mm<\/span>&#8220;<\/td>\n<\/tr>\n<tr>\n<td>&nbsp;end<\/td>\n<td>String<\/td>\n<td>&nbsp;<\/td>\n<td>\u8868\u793a\u6709\u6548\u65f6\u95f4\u8303\u56f4\u7684\u7ed3\u675f\uff0c\u5b57\u7b26\u4e32\u683c\u5f0f\u4e3a&#8221;<span style=\"color: #0000ff\">hh:mm<\/span>&#8220;<\/td>\n<\/tr>\n<tr>\n<td>&nbsp;bindchange<\/td>\n<td>EventHandle<\/td>\n<td>&nbsp;<\/td>\n<td>value\u6539\u53d8\u65f6\u89e6\u53d1change\u4e8b\u4ef6\uff0cevent.detail= { value:value}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u65e5\u671f\u9009\u62e9\u5668\uff1amode=date<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u5c5e\u6027\u540d<\/th>\n<th>\u7c7b\u578b<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>value<\/td>\n<td>String<\/td>\n<td>0<\/td>\n<td>\u8868\u793a\u9009\u4e2d\u7684\u65e5\u671f\uff0c\u683c\u5f0f\u4e3a&#8221;<span style=\"color: #0000ff\">yyyy-MM-dd<\/span>&#8220;<\/td>\n<\/tr>\n<tr>\n<td>start<\/td>\n<td>String<\/td>\n<td>&nbsp;<\/td>\n<td>\u8868\u793a\u6709\u6548\u65e5\u671f\u8303\u56f4\u7684\u5f00\u59cb\uff0c\u5b57\u7b26\u4e32\u683c\u5f0f\u4e3a&#8221;<span style=\"color: #0000ff\">yyyy-MM-dd<\/span>&#8220;<\/td>\n<\/tr>\n<tr>\n<td>end<\/td>\n<td>String<\/td>\n<td>&nbsp;<\/td>\n<td>\u8868\u793a\u6709\u6548\u65e5\u671f\u8303\u56f4\u7684\u7ed3\u675f\uff0c\u5b57\u7b26\u4e32\u683c\u5f0f\u4e3a&#8221;<span style=\"color: #0000ff\">yyyy-MM-dd<\/span>&#8220;<\/td>\n<\/tr>\n<tr>\n<td>fields<\/td>\n<td>String<\/td>\n<td>day<\/td>\n<td>\u6709\u6548\u503cyear,month,day\uff0c\u8868\u793a\u9009\u62e9\u5668\u7684\u7c92\u5ea6<\/td>\n<\/tr>\n<tr>\n<td>bindchange<\/td>\n<td>EventHandle<\/td>\n<td>&nbsp;<\/td>\n<td>value\u6539\u53d8\u65f6\u89e6\u53d1change\u4e8b\u4ef6\uff0cevent.detail= { value:value}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>picker.wxml\uff1a<\/p>\n<\/p>\n<pre>&lt;view&gt;\n&nbsp;&lt;view&gt;\u5730\u533a\u9009\u62e9\u5668&lt;\/view&gt;\n&nbsp;&lt;picker&gt;\n&nbsp;&lt;view&gt;\n&nbsp;&nbsp;\u5f53\u524d\u9009\u62e9\uff1a{{array[index]}}\n&nbsp;&lt;\/view&gt;\n&nbsp;&lt;\/picker&gt;&lt;\/view&gt;&lt;view&gt;\n&nbsp;&lt;view&gt;\u65f6\u95f4\u9009\u62e9\u5668&lt;\/view&gt;\n&nbsp;&lt;picker&gt;\n&nbsp;&lt;view&gt;\n&nbsp;&nbsp;\u5f53\u524d\u9009\u62e9:&nbsp;{{time}}\n&nbsp;&lt;\/view&gt;\n&nbsp;&lt;\/picker&gt;&lt;\/view&gt;&lt;view&gt;\n&nbsp;&lt;view&gt;\u65e5\u671f\u9009\u62e9\u5668&lt;\/view&gt;\n&nbsp;&lt;picker&gt;\n&nbsp;&lt;view&gt;\n&nbsp;&nbsp;\u5f53\u524d\u9009\u62e9:&nbsp;{{date}}\n&nbsp;&lt;\/view&gt;\n&nbsp;&lt;\/picker&gt;&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>picker.js\uff1a<\/p>\n<\/p>\n<pre>Page({\n&nbsp;data:&nbsp;{\n&nbsp;array:&nbsp;['\u7f8e\u56fd',&nbsp;'\u4e2d\u56fd',&nbsp;'\u5df4\u897f',&nbsp;'\u65e5\u672c'],\n&nbsp;index:&nbsp;0,\n&nbsp;date:&nbsp;'2016-09-01',\n&nbsp;time:&nbsp;'12:01'\n&nbsp;},\n&nbsp;bindPickerChange:&nbsp;function(e)&nbsp;{\n&nbsp;console.log('picker\u53d1\u9001\u9009\u62e9\u6539\u53d8\uff0c\u643a\u5e26\u503c\u4e3a',&nbsp;e.detail.value)\n&nbsp;this.setData({\n&nbsp;&nbsp;index:&nbsp;e.detail.value\n&nbsp;})\n&nbsp;},\n&nbsp;bindDateChange:&nbsp;function(e)&nbsp;{\n&nbsp;this.setData({\n&nbsp;&nbsp;date:&nbsp;e.detail.value\n&nbsp;})\n&nbsp;},\n&nbsp;bindTimeChange:&nbsp;function(e)&nbsp;{\n&nbsp;this.setData({\n&nbsp;&nbsp;time:&nbsp;e.detail.value\n&nbsp;})\n&nbsp;}\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7b80\u5355\u6837\u5f0f\u5e03\u5c40picker.wxss\uff1a<\/p>\n<\/p>\n<pre>.section&nbsp;{\n&nbsp;display:&nbsp;flex;\n&nbsp;flex-direction:&nbsp;column;\n&nbsp;padding:&nbsp;20rpx&nbsp;0rpx;\n&nbsp;color:&nbsp;#333;\n}\n.section__title{\n&nbsp;font-size:&nbsp;40rpx;\n&nbsp;margin:&nbsp;10rpx&nbsp;0rpx;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd0\u884c\u6548\u679c\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/009\/be907216ebc9788e3b894799dfa040c1-0.gif\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2dpicker\u7ec4\u4ef6\u7684\u7b80\u5355\u7528\u6cd5\u63d2\u56fe\" alt=\"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2dpicker\u7ec4\u4ef6\u7684\u7b80\u5355\u7528\u6cd5\u63d2\u56fe\" \/><\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff0c\u66f4\u591a\u76f8\u5173\u5185\u5bb9\u8bf7\u5173\u6ce8PHP\u4e2d\u6587\u7f51\uff01<\/p>\n<p>\u76f8\u5173\u63a8\u8350\uff1a<\/p>\n<p><\/p>\n<p><\/p>\n<\/p>\n<p><span><\/span><\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2dpicker\u7ec4\u4ef6\u7684\u7b80\u5355\u7528\u6cd5\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8fpicker\u7ec4\u4ef6\u7b80\u5355\u7528\u6cd5,\u7ed3\u5408\u5b9e\u4f8b\u5f62\u5f0f\u8be6\u7ec6\u5206\u6790\u4e86picker\u7ec4\u4ef6\u7684\u529f\u80fd\u3001\u4f7f\u7528\u65b9\u6cd5\u4e0e\u76f8\u5173\u6ce8\u610f\u4e8b\u9879,\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b \u672c\u6587\u5b9e\u4f8b\u8bb2\u8ff0\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8fpicker\u7ec4\u4ef6\u7b80\u5355\u7528\u6cd5\u3002\u5206\u4eab\u7ed9\u5927\u5bb6\u4f9b\u5927\u5bb6\u53c2\u8003\uff0c\u5177\u4f53\u5982\u4e0b\uff1a picker\u6eda\u52a8\u9009\u62e9\u5668\uff0c\u73b0\u652f\u6301\u4e09\u79cd\u9009\u62e9\u5668\uff0c\u901a\u8fc7mode\u6765\u533a\u5206\uff0c\u5206\u522b\u662f\u666e\u901a\u9009\u62e9\u5668\uff08mode=selector\uff09\uff0c\u65f6\u95f4\u9009\u62e9\u5668\uff08mode=time\uff09\uff0c\u65e5\u671f\u9009\u62e9\u5668\uff08mode=date\uff09\uff0c\u9ed8\u8ba4\u662f\u666e\u901a\u9009\u62e9\u5668\u3002 \u5177\u4f53\u529f\u80fd\u8bf4\u660e\u5982\u4e0b\uff1a \u666e\u901a\u9009\u62e9\u5668\uff1amode=selector \u5c5e\u6027\u540d \u7c7b\u578b \u9ed8\u8ba4\u503c \u8bf4\u660e range Array [] mode\u4e3aselector\u65f6\uff0crange\u6709\u6548 value Number 0 mode\u4e3aselector\u65f6\uff0c\u662f\u6570\u5b57\uff0c\u8868\u793a\u9009\u62e9\u4e86range\u4e2d\u7684\u7b2c\u51e0\u4e2a\uff0c\u4ece0\u5f00\u59cb\u3002 bindchange EventHandle &nbsp; value\u6539\u53d8\u65f6\u89e6\u53d1change\u4e8b\u4ef6\uff0cevent.detail= { value:value} \u65f6\u95f4\u9009\u62e9\u5668\uff1amode=time \u5c5e\u6027\u540d \u7c7b\u578b \u9ed8\u8ba4\u503c \u8bf4\u660e value String &nbsp; \u8868\u793a\u9009\u4e2d\u7684\u65f6\u95f4\uff0c\u683c\u5f0f\u4e3a&#8221;hh:mm&#8220; &nbsp;start String &nbsp; \u8868\u793a\u6709\u6548\u65f6\u95f4\u8303\u56f4\u7684\u5f00\u59cb\uff0c\u5b57\u7b26\u4e32\u683c\u5f0f\u4e3a&#8221;hh:mm&#8220; &nbsp;end String &nbsp; \u8868\u793a\u6709\u6548\u65f6\u95f4\u8303\u56f4\u7684\u7ed3\u675f\uff0c\u5b57\u7b26\u4e32\u683c\u5f0f\u4e3a&#8221;hh:mm&#8220; &nbsp;bindchange EventHandle &nbsp; value\u6539\u53d8\u65f6\u89e6\u53d1change\u4e8b\u4ef6\uff0cevent.detail= { value:value} \u65e5\u671f\u9009\u62e9\u5668\uff1amode=date \u5c5e\u6027\u540d \u7c7b\u578b \u9ed8\u8ba4\u503c \u8bf4\u660e value String 0 \u8868\u793a\u9009\u4e2d\u7684\u65e5\u671f\uff0c\u683c\u5f0f\u4e3a&#8221;yyyy-MM-dd&#8220; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-31823","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=31823"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31823\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}