{"id":30954,"date":"2024-11-25T10:22:20","date_gmt":"2024-11-25T02:22:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30954\/"},"modified":"2024-11-25T10:22:20","modified_gmt":"2024-11-25T02:22:20","slug":"%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e4%b8%ad%e5%85%b3%e4%ba%8e%e4%b8%89%e7%ba%a7%e8%81%94%e5%8a%a8%e5%9c%b0%e5%9d%80%e9%80%89%e6%8b%a9%e5%99%a8%e7%9a%84%e5%ae%9e%e4%be%8b%e5%88%86%e4%ba%ab","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30954\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u5173\u4e8e\u4e09\u7ea7\u8054\u52a8\u5730\u5740\u9009\u62e9\u5668\u7684\u5b9e\u4f8b\u5206\u4eab"},"content":{"rendered":"<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e09\u7ea7\u8054\u52a8\u5730\u5740\u9009\u62e9\u5668\u7684\u5b9e\u4f8b\u4ee3\u7801\uff0c\u5206\u4eab\u7ed9\u5927\u5bb6\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u4e00\u8d77\u4e86\u89e3\u4e00\u4e0b<\/p>\n<p>\u5728\u4e00\u4e9b\u7535\u5546\u7c7b\u7684\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u5730\u5740\u9009\u62e9\u8fd9\u4e2a\u529f\u80fd\u4e00\u822c\u662f\u5fc5\u5907\u7684\uff0c\u4e00\u822c\u7684\u6536\u8d27\u4fe1\u606f\u90fd\u9700\u8981\u6709\u4e00\u4e2a\u80fd\u9009\u62e9\u7701\u5e02\u53bf\u7684\u63a7\u4ef6\uff0c\u5f53\u7136\u4e5f\u6709\u4e9b\u4eba\u4e3a\u4e86\u7701\u4e8b\u5c31\u76f4\u63a5\u5199\u4e86\u4e00\u4e2a\u4f9b\u8f93\u5165\u7684input\uff0c\u90a3\u4e48\u8fd9\u6837\u505a\u7684\u7f3a\u70b9\u4e0d\u8a00\u800c\u55bb\uff0c\u800c\u4e14\u7528\u6237\u4f53\u9a8c\u4e5f\u4e0d\u662f\u90a3\u4e48\u7684\u597d\uff0c\u4eca\u5929\u7684\u8fd9\u7bc7\u6587\u7ae0\u5c31\u5206\u4eab\u4e00\u4e0b\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5730\u5740\u9009\u62e9\u7684\u5b9e\u73b0\u3002\u7701\u5e02\u53bf\u7684\u6570\u636e\u4ee5\u53ca\u533a\u57df\u7801\u53ef\u4ee5\u4ece\u56fd\u5bb6\u7edf\u8ba1\u5c40\u67e5\u8be2\u5230\uff0c\u5177\u4f53\u53ef\u4ee5\u81ea\u5df1\u641c\u4e00\u4e0b\u3002\u7167\u4f8b\u5148\u4e0a\u6e90\u7801\u548c\u6548\u679c\u56fe<\/p>\n<p>\u6e90\u7801\u4f20\u9001\u95e8<\/p>\n<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/194\/c87a47af27706ce44f78ddae4af10606-0.gif\" class=\"aligncenter\" title=\"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u5173\u4e8e\u4e09\u7ea7\u8054\u52a8\u5730\u5740\u9009\u62e9\u5668\u7684\u5b9e\u4f8b\u5206\u4eab\u63d2\u56fe\" alt=\"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u5173\u4e8e\u4e09\u7ea7\u8054\u52a8\u5730\u5740\u9009\u62e9\u5668\u7684\u5b9e\u4f8b\u5206\u4eab\u63d2\u56fe\" \/><\/strong><\/p>\n<p><strong>picker\u548cpicker-view\u7ec4\u4ef6<\/strong><\/p>\n<p>\u5728\u6b63\u5f0f\u4ecb\u7ecd\u5b9e\u73b0\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u6765\u4ecb\u7ecd\u4e0b\u8fd9\u4e24\u4e2a\u7ec4\u4ef6\uff0cpicker\u8fd9\u4e2a\u7ec4\u4ef6\u5728\u524d\u9762\u7684\u6587\u7ae0\u6709\u7b80\u5355\u4ecb\u7ecd\u8fc7\uff0c\u5b83\u662f\u4ece\u5e95\u90e8\u5f39\u8d77\u7684\u6eda\u52a8\u9009\u62e9\u5668\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6etype\u7684\u503c\u6765\u5b9e\u73b0\u65e5\u671f\u9009\u62e9\uff0c\u65f6\u95f4\u9009\u62e9\u4ee5\u53ca\u666e\u901a\u7684\u9009\u62e9\u5668\uff0c\u5982\u679c\u6211\u4eec\u60f3\u5b9e\u73b0\u4e0a\u56fe\u4e09\u7ea7\u8054\u52a8\u5730\u5740\u9009\u62e9\u6548\u679c\uff0c\u53d1\u73b0\u5b9e\u73b0\u8d77\u6765\u5f88\u56f0\u96be\uff0c\u5e94\u8be5\u8bf4\u662f\u4e0d\u80fd\u5b9e\u73b0\uff0c\u56e0\u4e3apicker\u666e\u901a\u9009\u62e9\u5668\u662f\u53ea\u80fd\u6709\u4e00\u5217\uff0c\u5982\u679c\u60f3\u8fd9\u5b9e\u73b0\u4e09\u5217\u7684\u6548\u679c\u5c31\u9700\u8981\u53e6\u8f9f\u8e4a\u5f84\u4e86\u3002<\/p>\n<p>\u65e2\u7136\u662f\u53e6\u8f9f\u8e4a\u5f84\uff0c\u81ea\u7136\u5c31\u4f1a\u60f3\u5230picker-view\uff0c\u8be5\u7ec4\u4ef6\u662f\u4e00\u4e2a\u5d4c\u5165\u9875\u9762\u7684\u6eda\u52a8\u9009\u62e9\u5668\uff0c\u8be5\u7ec4\u4ef6\u4e2d\u53ef\u4ee5\u653e\u7f6e\u591a\u4e2apicker-view-column\uff0c\u5e76\u4e14\u53ea\u80fd\u653e\u7f6epicker-view-column\uff0c\u5176\u5b83\u7ec4\u4ef6\u662f\u4e0d\u4f1a\u663e\u793a\u7684\uff0c\u6bcf\u4e00\u4e2apicker-view-column\u5c31\u662f\u4e00\u5217\u3002<\/p>\n<p>picker-view\u6709\u51e0\u4e2a\u91cd\u8981\u7684\u5c5e\u6027\uff0cvalue\u662f\u4e00\u4e2a\u6570\u7ec4\u7c7b\u578b\uff0c\u6570\u7ec4\u4e2d\u7684\u6570\u5b57\u4f9d\u6b21\u8868\u793a picker-view \u5185\u7684 picker-view-colume \u9009\u62e9\u7684\u7b2c\u51e0\u9879\uff08\u4e0b\u6807\u4ece 0 \u5f00\u59cb\uff09\uff0c\u6570\u5b57\u5927\u4e8e picker-view-column \u53ef\u9009\u9879\u957f\u5ea6\u65f6\uff0c\u9009\u62e9\u6700\u540e\u4e00\u9879\u3002indicator-style\u548cindicator-class\u53ef\u4ee5\u8bbe\u7f6e\u9009\u62e9\u5668\u4e2d\u95f4\u9009\u4e2d\u6846\u7684\u6837\u5f0f\uff0c\u4ed6\u6709\u4e00\u4e2a\u4e8b\u4ef6bindchange\uff0c\u5f53\u6211\u4eec\u6eda\u52a8item\u65f6\u9009\u62e9\u7684item\u6570\u636e\u53d1\u751f\u53d8\u5316\u5c31\u4f1a\u89e6\u53d1\u8fd9\u4e2a\u51fd\u6570\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7event.detai.vaule\uff08\u548c\u4e0a\u9762\u4ecb\u7ecdvaule\u542b\u4e49\u76f8\u540c\uff09\u83b7\u53d6\u5f53\u524d\u9009\u62e9\u7684\u662f\u7b2c\u51e0\u9879\uff08\u4e0b\u6807\u4ece 0 \u5f00\u59cb\uff09\u3002\u800c\u5bf9\u4e8epicker-view-column\u9ad8\u5ea6\u4f1a\u81ea\u52a8\u8bbe\u7f6e\u6210\u4e0epicker-view\u7684\u9009\u4e2d\u6846\u7684\u9ad8\u5ea6\u4e00\u81f4\u3002<\/p>\n<p>\u7701\u5e02\u53bf\u6570\u636e\u6587\u4ef6 \u5b58\u50a8\u4e86\u5730\u5740\u9009\u62e9\u6240\u9700\u8981\u7528\u5230\u7684\u6570\u636e\uff0c\u4e3b\u8981\u662f\u533a\u57df\u7801\u548c\u540d\u5b57\uff0c\u7136\u540e\u901a\u8fc7\u4e0b\u9762\u4ee3\u7801\u5c06\u6570\u636e\u66b4\u9732\u51fa\u53bb\uff0c\u4ee5\u4f9b\u4f7f\u7528<\/p>\n<p><\/p>\n<pre>module.exports&nbsp;=&nbsp;{\r\n&nbsp;citys,\r\n&nbsp;provinces,\r\n&nbsp;areas\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>wxml\u6587\u4ef6\u5b9e\u73b0<\/p>\n<p><\/p>\n<pre>&lt;view&gt;\r\n&nbsp;&lt;view&gt;\r\n&nbsp;&nbsp;&lt;text&gt;\u53d6\u6d88&lt;\/text&gt;\r\n&nbsp;&nbsp;&lt;text&gt;\u786e\u5b9a&lt;\/text&gt;\r\n&nbsp;&lt;\/view&gt;\r\n&nbsp;&lt;picker-view&gt;\r\n&nbsp;&nbsp;&lt;picker-view-column&gt;\r\n&nbsp;&nbsp;&nbsp;&lt;view&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;{{item.name}}&lt;\/view&gt;\r\n&nbsp;&nbsp;&lt;\/picker-view-column&gt;\r\n&nbsp;&nbsp;&lt;picker-view-column&gt;\r\n&nbsp;&nbsp;&nbsp;&lt;view&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;{{item.name}}&lt;\/view&gt;\r\n&nbsp;&nbsp;&lt;\/picker-view-column&gt;\r\n&nbsp;&nbsp;&lt;picker-view-column&gt;\r\n&nbsp;&nbsp;&nbsp;&lt;view&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;{{item.name}}&lt;\/view&gt;\r\n&nbsp;&nbsp;&lt;\/picker-view-column&gt;\r\n&nbsp;&lt;\/picker-view&gt;&lt;\/view&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4e3b\u8981\u5c31\u662f\u4e0a\u9762\u6709\u4e00\u4e2a\u53d6\u6d88\u548c\u786e\u5b9a\u4f9b\u7528\u6237\u70b9\u51fb\u786e\u8ba4\u9009\u62e9\uff0c\u4ee5\u53capicker-view \u4e2d\u5305\u542b\u4e09\u4e2apicker-view-column\u7ec4\u4ef6\uff0c\u5206\u522b\u5bf9\u5e94\u663e\u793a\u7701\u5e02\u533a\uff0cprovinces\uff0ccitys\uff0careas\u662f\u5bf9\u5e94\u7684\u6570\u636e\uff0canimation\u662f\u9009\u62e9\u63a7\u4ef6\u53ef\u89c1\u6216\u8005\u4e0d\u53ef\u89c1\u65f6\u7684\u8fc7\u6e21\u52a8\u753b\u3002<\/p>\n<p>\u6837\u5f0fwxss\u6587\u4ef6<\/p>\n<p><\/p>\n<pre>.picker-view&nbsp;{\r\n&nbsp;width:&nbsp;100%;\r\n&nbsp;display:&nbsp;flex;\r\n&nbsp;z-index:12;\r\n&nbsp;background-color:&nbsp;#fff;\r\n&nbsp;flex-direction:&nbsp;column;\r\n&nbsp;justify-content:&nbsp;center;\r\n&nbsp;align-items:&nbsp;center;\r\n&nbsp;position:&nbsp;fixed;\r\n&nbsp;bottom:&nbsp;0rpx;\r\n&nbsp;left:&nbsp;0rpx;\r\n&nbsp;height:&nbsp;40vh;\r\n}\r\n\r\n.picker-item&nbsp;{\r\n&nbsp;line-height:&nbsp;70rpx;\r\n&nbsp;margin-left:&nbsp;5rpx;\r\n&nbsp;margin-right:&nbsp;5rpx;\r\n&nbsp;text-align:&nbsp;center;\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728js\u4e2d\u6211\u4eec\u5728data\u4e2d\u52a0\u5165\u6570\u636e<\/p>\n<p><\/p>\n<pre>\/**\r\n&nbsp;&nbsp;*&nbsp;\u63a7\u4ef6\u5f53\u524d\u663e\u793a\u7684\u6570\u636e\r\n&nbsp;&nbsp;*&nbsp;provinces:\u6240\u6709\u7701\u4efd\r\n&nbsp;&nbsp;*&nbsp;citys&nbsp;\u9009\u62e9\u7701\u5bf9\u5e94\u7684\u6240\u6709\u5e02,\r\n&nbsp;&nbsp;*&nbsp;areas\u9009\u62e9\u5e02\u5bf9\u5e94\u7684\u6240\u6709\u533a\r\n&nbsp;&nbsp;*&nbsp;areaInfo\uff1a\u70b9\u51fb\u786e\u5b9a\u65f6\u9009\u62e9\u7684\u7701\u5e02\u53bf\u5b57\u7b26\u62fc\u63a5\r\n&nbsp;&nbsp;*&nbsp;animationAddressMenu\uff1a\u52a8\u753b\r\n&nbsp;&nbsp;*&nbsp;addressMenuIsShow\uff1a\u662f\u5426\u53ef\u89c1\r\n&nbsp;&nbsp;*\/\r\n&nbsp;data:&nbsp;{\r\n&nbsp;&nbsp;animationAddressMenu:&nbsp;{},\r\n&nbsp;&nbsp;addressMenuIsShow:&nbsp;false,\r\n&nbsp;&nbsp;value:&nbsp;[0,&nbsp;0,&nbsp;0],\r\n&nbsp;&nbsp;provinces:&nbsp;[],\r\n&nbsp;&nbsp;citys:&nbsp;[],\r\n&nbsp;&nbsp;areas:&nbsp;[],\r\n&nbsp;&nbsp;areaInfo:''\r\n&nbsp;},<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6700\u91cd\u8981\u7684\u662f\u5728js\u6587\u4ef6\u5f00\u59cb\u5904\u5f15\u5165\u6570\u636e\u6587\u4ef6<\/p>\n<p><\/p>\n<pre>var&nbsp;address&nbsp;=&nbsp;require('..\/..\/utils\/city.js')<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>onLoad\u4e2d\u521d\u59cb\u5316\u6570\u636e,\u9ed8\u8ba4\u663e\u793a\u5317\u4eac<\/p>\n<p><\/p>\n<pre>\/\/&nbsp;\u9ed8\u8ba4\u8054\u52a8\u663e\u793a\u5317\u4eac\r\n&nbsp;&nbsp;var&nbsp;id&nbsp;=&nbsp;address.provinces[0].id\r\n&nbsp;&nbsp;this.setData({\r\n&nbsp;&nbsp;&nbsp;provinces:&nbsp;address.provinces,\r\n&nbsp;&nbsp;&nbsp;citys:&nbsp;address.citys[id],\r\n&nbsp;&nbsp;&nbsp;areas:&nbsp;address.areas[address.citys[id][0].id],\r\n&nbsp;&nbsp;})<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4e8b\u4ef6\u7684\u5904\u7406\u903b\u8f91\uff1a<\/p>\n<p><\/p>\n<pre>\/\/&nbsp;\u70b9\u51fb\u6240\u5728\u5730\u533a\u5f39\u51fa\u9009\u62e9\u6846\r\n&nbsp;selectDistrict:&nbsp;function&nbsp;(e)&nbsp;{\r\n&nbsp;&nbsp;var&nbsp;that&nbsp;=&nbsp;this\r\n&nbsp;&nbsp;\/\/&nbsp;\u5982\u679c\u5df2\u7ecf\u663e\u793a\uff0c\u4e0d\u5728\u6267\u884c\u663e\u793a\u52a8\u753b\r\n&nbsp;&nbsp;if&nbsp;(that.data.addressMenuIsShow)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;return\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;\/\/&nbsp;\u6267\u884c\u663e\u793a\u52a8\u753b\r\n&nbsp;&nbsp;that.startAddressAnimation(true)\r\n&nbsp;},\r\n&nbsp;\/\/&nbsp;\u6267\u884c\u52a8\u753b\r\n&nbsp;startAddressAnimation:&nbsp;function&nbsp;(isShow)&nbsp;{\r\n&nbsp;&nbsp;console.log(isShow)\r\n&nbsp;&nbsp;var&nbsp;that&nbsp;=&nbsp;this\r\n&nbsp;&nbsp;if&nbsp;(isShow)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;\/\/&nbsp;vh\u662f\u7528\u6765\u8868\u793a\u5c3a\u5bf8\u7684\u5355\u4f4d\uff0c\u9ad8\u5ea6\u5168\u5c4f\u662f100vh\r\n&nbsp;&nbsp;&nbsp;that.animation.translateY(0&nbsp;+&nbsp;'vh').step()\r\n&nbsp;&nbsp;}&nbsp;else&nbsp;{\r\n&nbsp;&nbsp;&nbsp;that.animation.translateY(40&nbsp;+&nbsp;'vh').step()\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;that.setData({\r\n&nbsp;&nbsp;&nbsp;animationAddressMenu:&nbsp;that.animation.export(),\r\n&nbsp;&nbsp;&nbsp;addressMenuIsShow:&nbsp;isShow,\r\n&nbsp;&nbsp;})\r\n&nbsp;},\r\n&nbsp;\/\/&nbsp;\u70b9\u51fb\u5730\u533a\u9009\u62e9\u53d6\u6d88\u6309\u94ae\r\n&nbsp;cityCancel:&nbsp;function&nbsp;(e)&nbsp;{\r\n&nbsp;&nbsp;this.startAddressAnimation(false)\r\n&nbsp;},\r\n&nbsp;\/\/&nbsp;\u70b9\u51fb\u5730\u533a\u9009\u62e9\u786e\u5b9a\u6309\u94ae\r\n&nbsp;citySure:&nbsp;function&nbsp;(e)&nbsp;{\r\n&nbsp;&nbsp;var&nbsp;that&nbsp;=&nbsp;this\r\n&nbsp;&nbsp;var&nbsp;city&nbsp;=&nbsp;that.data.city\r\n&nbsp;&nbsp;var&nbsp;value&nbsp;=&nbsp;that.data.value\r\n&nbsp;&nbsp;that.startAddressAnimation(false)\r\n&nbsp;&nbsp;\/\/&nbsp;\u5c06\u9009\u62e9\u7684\u57ce\u5e02\u4fe1\u606f\u663e\u793a\u5230\u8f93\u5165\u6846\r\n&nbsp;&nbsp;var&nbsp;areaInfo&nbsp;=&nbsp;that.data.provinces[value[0]].name&nbsp;+&nbsp;','&nbsp;+&nbsp;that.data.citys[value[1]].name&nbsp;+&nbsp;','&nbsp;+&nbsp;that.data.areas[value[2]].name\r\n&nbsp;&nbsp;that.setData({\r\n&nbsp;&nbsp;&nbsp;areaInfo:&nbsp;areaInfo,\r\n&nbsp;&nbsp;})\r\n&nbsp;},\r\n&nbsp;\/\/&nbsp;\u70b9\u51fb\u8499\u7248\u65f6\u53d6\u6d88\u7ec4\u4ef6\u7684\u663e\u793a\r\n&nbsp;hideCitySelected:&nbsp;function&nbsp;(e)&nbsp;{\r\n&nbsp;&nbsp;console.log(e)\r\n&nbsp;&nbsp;this.startAddressAnimation(false)\r\n&nbsp;},\r\n&nbsp;\/\/&nbsp;\u5904\u7406\u7701\u5e02\u53bf\u8054\u52a8\u903b\u8f91\r\n&nbsp;cityChange:&nbsp;function&nbsp;(e)&nbsp;{\r\n&nbsp;&nbsp;console.log(e)\r\n&nbsp;&nbsp;var&nbsp;value&nbsp;=&nbsp;e.detail.value\r\n&nbsp;&nbsp;var&nbsp;provinces&nbsp;=&nbsp;this.data.provinces\r\n&nbsp;&nbsp;var&nbsp;citys&nbsp;=&nbsp;this.data.citys\r\n&nbsp;&nbsp;var&nbsp;areas&nbsp;=&nbsp;this.data.areas\r\n&nbsp;&nbsp;var&nbsp;provinceNum&nbsp;=&nbsp;value[0]\r\n&nbsp;&nbsp;var&nbsp;cityNum&nbsp;=&nbsp;value[1]\r\n&nbsp;&nbsp;var&nbsp;countyNum&nbsp;=&nbsp;value[2]\r\n&nbsp;&nbsp;\/\/&nbsp;\u5982\u679c\u7701\u4efd\u9009\u62e9\u9879\u548c\u4e4b\u524d\u4e0d\u4e00\u6837\uff0c\u8868\u793a\u6ed1\u52a8\u4e86\u7701\u4efd\uff0c\u6b64\u65f6\u5e02\u9ed8\u8ba4\u662f\u7701\u7684\u7b2c\u4e00\u7ec4\u6570\u636e\uff0c\r\n&nbsp;&nbsp;if&nbsp;(this.data.value[0]&nbsp;!=&nbsp;provinceNum)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;var&nbsp;id&nbsp;=&nbsp;provinces[provinceNum].id\r\n&nbsp;&nbsp;&nbsp;this.setData({\r\n&nbsp;&nbsp;&nbsp;&nbsp;value:&nbsp;[provinceNum,&nbsp;0,&nbsp;0],\r\n&nbsp;&nbsp;&nbsp;&nbsp;citys:&nbsp;address.citys[id],\r\n&nbsp;&nbsp;&nbsp;&nbsp;areas:&nbsp;address.areas[address.citys[id][0].id],\r\n&nbsp;&nbsp;&nbsp;})\r\n&nbsp;&nbsp;}&nbsp;else&nbsp;if&nbsp;(this.data.value[1]&nbsp;!=&nbsp;cityNum)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u6ed1\u52a8\u9009\u62e9\u4e86\u7b2c\u4e8c\u9879\u6570\u636e\uff0c\u5373\u5e02\uff0c\u6b64\u65f6\u533a\u663e\u793a\u7701\u5e02\u5bf9\u5e94\u7684\u7b2c\u4e00\u7ec4\u6570\u636e\r\n&nbsp;&nbsp;&nbsp;var&nbsp;id&nbsp;=&nbsp;citys[cityNum].id\r\n&nbsp;&nbsp;&nbsp;this.setData({\r\n&nbsp;&nbsp;&nbsp;&nbsp;value:&nbsp;[provinceNum,&nbsp;cityNum,&nbsp;0],\r\n&nbsp;&nbsp;&nbsp;&nbsp;areas:&nbsp;address.areas[citys[cityNum].id],\r\n&nbsp;&nbsp;&nbsp;})\r\n&nbsp;&nbsp;}&nbsp;else&nbsp;{\r\n&nbsp;&nbsp;&nbsp;\/\/&nbsp;\u6ed1\u52a8\u9009\u62e9\u4e86\u533a\r\n&nbsp;&nbsp;&nbsp;this.setData({\r\n&nbsp;&nbsp;&nbsp;&nbsp;value:&nbsp;[provinceNum,&nbsp;cityNum,&nbsp;countyNum]\r\n&nbsp;&nbsp;&nbsp;})\r\n&nbsp;&nbsp;}\r\n&nbsp;&nbsp;console.log(this.data)\r\n&nbsp;},<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5bf9\u4e8e\u4e8b\u4ef6\u5904\u7406\uff0c\u8054\u52a8\u7684\u5904\u7406\u903b\u8f91\uff0c\u9700\u8981\u89e3\u91ca\u7684\u6211\u5df2\u5728\u4ee3\u7801\u5b9e\u73b0\u4e2d\u505a\u4e86\u89e3\u91ca\uff0c\u4e5f\u6ca1\u6709\u4ec0\u4e48\u6bd4\u8f83\u96be\u4ee5\u7406\u89e3\u7684\u5185\u5bb9\uff0c\u5c31\u4e0d\u5728\u8fc7\u591a\u4ecb\u7ecd\uff0c\u5230\u8fd9\u91cc\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7701\u5e02\u53bf\u4e09\u7ea7\u8054\u52a8\u6548\u679c\u5df2\u7ecf\u5b9e\u73b0\u4e86\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u5173\u4e8e\u4e09\u7ea7\u8054\u52a8\u5730\u5740\u9009\u62e9\u5668\u7684\u5b9e\u4f8b\u5206\u4eab\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>\u672c\u6587\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e09\u7ea7\u8054\u52a8\u5730\u5740\u9009\u62e9\u5668\u7684\u5b9e\u4f8b\u4ee3\u7801\uff0c\u5206\u4eab\u7ed9\u5927\u5bb6\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u4e00\u8d77\u4e86\u89e3\u4e00\u4e0b \u5728\u4e00\u4e9b\u7535\u5546\u7c7b\u7684\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u5730\u5740\u9009\u62e9\u8fd9\u4e2a\u529f\u80fd\u4e00\u822c\u662f\u5fc5\u5907\u7684\uff0c\u4e00\u822c\u7684\u6536\u8d27\u4fe1\u606f\u90fd\u9700\u8981\u6709\u4e00\u4e2a\u80fd\u9009\u62e9\u7701\u5e02\u53bf\u7684\u63a7\u4ef6\uff0c\u5f53\u7136\u4e5f\u6709\u4e9b\u4eba\u4e3a\u4e86\u7701\u4e8b\u5c31\u76f4\u63a5\u5199\u4e86\u4e00\u4e2a\u4f9b\u8f93\u5165\u7684input\uff0c\u90a3\u4e48\u8fd9\u6837\u505a\u7684\u7f3a\u70b9\u4e0d\u8a00\u800c\u55bb\uff0c\u800c\u4e14\u7528\u6237\u4f53\u9a8c\u4e5f\u4e0d\u662f\u90a3\u4e48\u7684\u597d\uff0c\u4eca\u5929\u7684\u8fd9\u7bc7\u6587\u7ae0\u5c31\u5206\u4eab\u4e00\u4e0b\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5730\u5740\u9009\u62e9\u7684\u5b9e\u73b0\u3002\u7701\u5e02\u53bf\u7684\u6570\u636e\u4ee5\u53ca\u533a\u57df\u7801\u53ef\u4ee5\u4ece\u56fd\u5bb6\u7edf\u8ba1\u5c40\u67e5\u8be2\u5230\uff0c\u5177\u4f53\u53ef\u4ee5\u81ea\u5df1\u641c\u4e00\u4e0b\u3002\u7167\u4f8b\u5148\u4e0a\u6e90\u7801\u548c\u6548\u679c\u56fe \u6e90\u7801\u4f20\u9001\u95e8 picker\u548cpicker-view\u7ec4\u4ef6 \u5728\u6b63\u5f0f\u4ecb\u7ecd\u5b9e\u73b0\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u5148\u6765\u4ecb\u7ecd\u4e0b\u8fd9\u4e24\u4e2a\u7ec4\u4ef6\uff0cpicker\u8fd9\u4e2a\u7ec4\u4ef6\u5728\u524d\u9762\u7684\u6587\u7ae0\u6709\u7b80\u5355\u4ecb\u7ecd\u8fc7\uff0c\u5b83\u662f\u4ece\u5e95\u90e8\u5f39\u8d77\u7684\u6eda\u52a8\u9009\u62e9\u5668\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6etype\u7684\u503c\u6765\u5b9e\u73b0\u65e5\u671f\u9009\u62e9\uff0c\u65f6\u95f4\u9009\u62e9\u4ee5\u53ca\u666e\u901a\u7684\u9009\u62e9\u5668\uff0c\u5982\u679c\u6211\u4eec\u60f3\u5b9e\u73b0\u4e0a\u56fe\u4e09\u7ea7\u8054\u52a8\u5730\u5740\u9009\u62e9\u6548\u679c\uff0c\u53d1\u73b0\u5b9e\u73b0\u8d77\u6765\u5f88\u56f0\u96be\uff0c\u5e94\u8be5\u8bf4\u662f\u4e0d\u80fd\u5b9e\u73b0\uff0c\u56e0\u4e3apicker\u666e\u901a\u9009\u62e9\u5668\u662f\u53ea\u80fd\u6709\u4e00\u5217\uff0c\u5982\u679c\u60f3\u8fd9\u5b9e\u73b0\u4e09\u5217\u7684\u6548\u679c\u5c31\u9700\u8981\u53e6\u8f9f\u8e4a\u5f84\u4e86\u3002 \u65e2\u7136\u662f\u53e6\u8f9f\u8e4a\u5f84\uff0c\u81ea\u7136\u5c31\u4f1a\u60f3\u5230picker-view\uff0c\u8be5\u7ec4\u4ef6\u662f\u4e00\u4e2a\u5d4c\u5165\u9875\u9762\u7684\u6eda\u52a8\u9009\u62e9\u5668\uff0c\u8be5\u7ec4\u4ef6\u4e2d\u53ef\u4ee5\u653e\u7f6e\u591a\u4e2apicker-view-column\uff0c\u5e76\u4e14\u53ea\u80fd\u653e\u7f6epicker-view-column\uff0c\u5176\u5b83\u7ec4\u4ef6\u662f\u4e0d\u4f1a\u663e\u793a\u7684\uff0c\u6bcf\u4e00\u4e2apicker-view-column\u5c31\u662f\u4e00\u5217\u3002 picker-view\u6709\u51e0\u4e2a\u91cd\u8981\u7684\u5c5e\u6027\uff0cvalue\u662f\u4e00\u4e2a\u6570\u7ec4\u7c7b\u578b\uff0c\u6570\u7ec4\u4e2d\u7684\u6570\u5b57\u4f9d\u6b21\u8868\u793a picker-view \u5185\u7684 picker-view-colume \u9009\u62e9\u7684\u7b2c\u51e0\u9879\uff08\u4e0b\u6807\u4ece 0 \u5f00\u59cb\uff09\uff0c\u6570\u5b57\u5927\u4e8e picker-view-column \u53ef\u9009\u9879\u957f\u5ea6\u65f6\uff0c\u9009\u62e9\u6700\u540e\u4e00\u9879\u3002indicator-style\u548cindicator-class\u53ef\u4ee5\u8bbe\u7f6e\u9009\u62e9\u5668\u4e2d\u95f4\u9009\u4e2d\u6846\u7684\u6837\u5f0f\uff0c\u4ed6\u6709\u4e00\u4e2a\u4e8b\u4ef6bindchange\uff0c\u5f53\u6211\u4eec\u6eda\u52a8item\u65f6\u9009\u62e9\u7684item\u6570\u636e\u53d1\u751f\u53d8\u5316\u5c31\u4f1a\u89e6\u53d1\u8fd9\u4e2a\u51fd\u6570\uff0c\u5e76\u4e14\u53ef\u4ee5\u901a\u8fc7event.detai.vaule\uff08\u548c\u4e0a\u9762\u4ecb\u7ecdvaule\u542b\u4e49\u76f8\u540c\uff09\u83b7\u53d6\u5f53\u524d\u9009\u62e9\u7684\u662f\u7b2c\u51e0\u9879\uff08\u4e0b\u6807\u4ece 0 \u5f00\u59cb\uff09\u3002\u800c\u5bf9\u4e8epicker-view-column\u9ad8\u5ea6\u4f1a\u81ea\u52a8\u8bbe\u7f6e\u6210\u4e0epicker-view\u7684\u9009\u4e2d\u6846\u7684\u9ad8\u5ea6\u4e00\u81f4\u3002 \u7701\u5e02\u53bf\u6570\u636e\u6587\u4ef6 \u5b58\u50a8\u4e86\u5730\u5740\u9009\u62e9\u6240\u9700\u8981\u7528\u5230\u7684\u6570\u636e\uff0c\u4e3b\u8981\u662f\u533a\u57df\u7801\u548c\u540d\u5b57\uff0c\u7136\u540e\u901a\u8fc7\u4e0b\u9762\u4ee3\u7801\u5c06\u6570\u636e\u66b4\u9732\u51fa\u53bb\uff0c\u4ee5\u4f9b\u4f7f\u7528 module.exports&nbsp;=&nbsp;{ &nbsp;citys, &nbsp;provinces, &nbsp;areas } \u767b\u5f55\u540e\u590d\u5236 wxml\u6587\u4ef6\u5b9e\u73b0 &lt;view&gt; &nbsp;&lt;view&gt; &nbsp;&nbsp;&lt;text&gt;\u53d6\u6d88&lt;\/text&gt; &nbsp;&nbsp;&lt;text&gt;\u786e\u5b9a&lt;\/text&gt; &nbsp;&lt;\/view&gt; &nbsp;&lt;picker-view&gt; &nbsp;&nbsp;&lt;picker-view-column&gt; &nbsp;&nbsp;&nbsp;&lt;view&gt; &nbsp;&nbsp;&nbsp;&nbsp;{{item.name}}&lt;\/view&gt; &nbsp;&nbsp;&lt;\/picker-view-column&gt; &nbsp;&nbsp;&lt;picker-view-column&gt; &nbsp;&nbsp;&nbsp;&lt;view&gt; &nbsp;&nbsp;&nbsp;&nbsp;{{item.name}}&lt;\/view&gt; &nbsp;&nbsp;&lt;\/picker-view-column&gt; &nbsp;&nbsp;&lt;picker-view-column&gt; &nbsp;&nbsp;&nbsp;&lt;view&gt; &nbsp;&nbsp;&nbsp;&nbsp;{{item.name}}&lt;\/view&gt; &nbsp;&nbsp;&lt;\/picker-view-column&gt; &nbsp;&lt;\/picker-view&gt;&lt;\/view&gt; \u767b\u5f55\u540e\u590d\u5236 \u4e3b\u8981\u5c31\u662f\u4e0a\u9762\u6709\u4e00\u4e2a\u53d6\u6d88\u548c\u786e\u5b9a\u4f9b\u7528\u6237\u70b9\u51fb\u786e\u8ba4\u9009\u62e9\uff0c\u4ee5\u53capicker-view \u4e2d\u5305\u542b\u4e09\u4e2apicker-view-column\u7ec4\u4ef6\uff0c\u5206\u522b\u5bf9\u5e94\u663e\u793a\u7701\u5e02\u533a\uff0cprovinces\uff0ccitys\uff0careas\u662f\u5bf9\u5e94\u7684\u6570\u636e\uff0canimation\u662f\u9009\u62e9\u63a7\u4ef6\u53ef\u89c1\u6216\u8005\u4e0d\u53ef\u89c1\u65f6\u7684\u8fc7\u6e21\u52a8\u753b\u3002 \u6837\u5f0fwxss\u6587\u4ef6 .picker-view&nbsp;{ &nbsp;width:&nbsp;100%; &nbsp;display:&nbsp;flex; &nbsp;z-index:12; &nbsp;background-color:&nbsp;#fff; &nbsp;flex-direction:&nbsp;column; [&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-30954","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30954","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=30954"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30954\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}