{"id":28587,"date":"2024-11-25T08:31:44","date_gmt":"2024-11-25T00:31:44","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28587\/"},"modified":"2024-11-25T08:31:44","modified_gmt":"2024-11-25T00:31:44","slug":"%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e7%bb%84%e4%bb%b6%e5%8c%96%e5%bc%80%e5%8f%91labrador%e6%a1%86%e6%9e%b6%e7%9a%84%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28587\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7ec4\u4ef6\u5316\u5f00\u53d1Labrador\u6846\u67b6\u7684\u4ecb\u7ecd"},"content":{"rendered":"<p style=\"padding: 0px 0px 0.3em;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">labrador \u547d\u4ee4<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">labrador init \u521d\u59cb\u5316\u9879\u76ee\u547d\u4ee4<\/p>\n<p>\u6ce8\u610f\u6b64\u547d\u4ee4\u4f1a\u521d\u59cb\u5316\u5f53\u524d\u7684\u76ee\u5f55\u4e3a\u9879\u76ee\u76ee\u5f55\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">labrador build \u6784\u5efa\u5f53\u524d\u9879\u76ee<\/p>\n<pre>&nbsp;&nbsp;Usage:&nbsp;labrador&nbsp;build&nbsp;[options]\r\n\r\n&nbsp;&nbsp;Options:\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;-h,&nbsp;--help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output&nbsp;usage&nbsp;information\r\n&nbsp;&nbsp;&nbsp;&nbsp;-V,&nbsp;--version&nbsp;&nbsp;output&nbsp;the&nbsp;version&nbsp;number\r\n&nbsp;&nbsp;&nbsp;&nbsp;-c,&nbsp;--catch&nbsp;&nbsp;&nbsp;&nbsp;\u5728\u8f7d\u5165\u65f6\u81ea\u52a8catch\u6240\u6709JS\u811a\u672c\u7684\u9519\u8bef\r\n&nbsp;&nbsp;&nbsp;&nbsp;-t,&nbsp;--test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd0\u884c\u6d4b\u8bd5\u811a\u672c\r\n&nbsp;&nbsp;&nbsp;&nbsp;-d,&nbsp;--debug&nbsp;&nbsp;&nbsp;&nbsp;DEBUG\u6a21\u5f0f\r\n&nbsp;&nbsp;&nbsp;&nbsp;-m,&nbsp;--minify&nbsp;&nbsp;&nbsp;\u538b\u7f29\u4ee3\u7801\r\n&nbsp;&nbsp;&nbsp;&nbsp;-f,&nbsp;--force&nbsp;&nbsp;&nbsp;&nbsp;\u5f3a\u5236\u6784\u5efa\uff0c\u4e0d\u4f7f\u7528\u7f13\u5b58<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">labrador watch \u76d1\u6d4b\u6587\u4ef6\u53d8\u5316<\/p>\n<pre>&nbsp;&nbsp;Usage:&nbsp;labrador&nbsp;watch&nbsp;[options]\r\n\r\n&nbsp;&nbsp;Options:\r\n\r\n&nbsp;&nbsp;&nbsp;&nbsp;-h,&nbsp;--help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output&nbsp;usage&nbsp;information\r\n&nbsp;&nbsp;&nbsp;&nbsp;-V,&nbsp;--version&nbsp;&nbsp;output&nbsp;the&nbsp;version&nbsp;number\r\n&nbsp;&nbsp;&nbsp;&nbsp;-c,&nbsp;--catch&nbsp;&nbsp;&nbsp;&nbsp;\u5728\u8f7d\u5165\u65f6\u81ea\u52a8catch\u6240\u6709JS\u811a\u672c\u7684\u9519\u8bef\r\n&nbsp;&nbsp;&nbsp;&nbsp;-t,&nbsp;--test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd0\u884c\u6d4b\u8bd5\u811a\u672c\r\n&nbsp;&nbsp;&nbsp;&nbsp;-d,&nbsp;--debug&nbsp;&nbsp;&nbsp;&nbsp;DEBUG\u6a21\u5f0f<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p style=\"padding: 0px 0px 0.3em;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">labrador \u5e93<\/p>\n<p>labrador&nbsp;\u5e93\u5bf9\u5168\u5c40\u7684&nbsp;wx&nbsp;\u53d8\u91cf\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u5c06\u5927\u90e8\u5206&nbsp;wx&nbsp;\u5bf9\u8c61\u4e2d\u7684\u65b9\u6cd5\u8fdb\u884c\u4e86Promise\u652f\u6301\uff0c \u9664\u4e86\u4ee5&nbsp;on*&nbsp;\u5f00\u5934\u6216\u4ee5&nbsp;*Sync\u7ed3\u5c3e\u7684\u65b9\u6cd5\u3002\u5728\u5982\u4e0b\u4ee3\u7801\u4e2d\u4f7f\u7528&nbsp;labrador&nbsp;\u5e93\u3002<\/p>\n<pre>import&nbsp;wx&nbsp;from&nbsp;'labrador';console.log(wx.version);wx.app;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n\/\/&nbsp;\u548c\u5168\u5c40\u7684&nbsp;getApp()&nbsp;\u51fd\u6570\u6548\u679c\u4e00\u6837\uff0c\u4ee3\u7801\u98ce\u683c\u4e0d\u5efa\u8bae\u7c97\u66b4\u5730\u8bbf\u95ee\u5168\u5c40\u5bf9\u8c61\u548c\u65b9\u6cd5wx.Component;&nbsp;&nbsp;&nbsp;\r\n\/\/&nbsp;Labrador&nbsp;\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u57fa\u7c7bwx.List;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n\/\/&nbsp;Labrador&nbsp;\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5217\u8868\u7c7bwx.PropTypes;&nbsp;&nbsp;&nbsp;\r\n\/\/&nbsp;Labrador&nbsp;\u6570\u636e\u7c7b\u578b\u6821\u9a8c\u5668\u96c6\u5408wx.login;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n\/\/&nbsp;\u5c01\u88c5\u540e\u7684\u5fae\u4fe1\u767b\u5f55\u63a5\u53e3wx.getStorage;&nbsp;&nbsp;\r\n\/\/&nbsp;\u5c01\u88c5\u540e\u7684\u8bfb\u53d6\u7f13\u5b58\u63a5\u53e3<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6211\u4eec\u5efa\u8bae\u4e0d\u8981\u518d\u4f7f\u7528&nbsp;wx.getStorageSync()&nbsp;\u7b49\u540c\u6b65\u963b\u585e\u65b9\u6cd5\uff0c\u800c\u5728&nbsp;async&nbsp;\u51fd\u6570\u4e2d\u4f7f\u7528&nbsp;await wx.getStorage()&nbsp;\u5f02\u6b65\u975e\u963b\u585e\u65b9\u6cd5\u63d0\u9ad8\u6027\u80fd\uff0c\u9664\u975e\u9047\u5230\u7279\u6b8a\u60c5\u51b5\u3002<\/p>\n<p style=\"padding: 0px 0px 0.3em;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">app.js<\/p>\n<p>src\/app.js&nbsp;\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>import&nbsp;wx&nbsp;from&nbsp;'labrador';import&nbsp;{sleep}&nbsp;from&nbsp;'.\/utils\/util';export&nbsp;default&nbsp;class&nbsp;{\r\n&nbsp;&nbsp;globalData&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;userInfo:&nbsp;null\r\n&nbsp;&nbsp;};&nbsp;&nbsp;async&nbsp;onLaunch()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u8c03\u7528API\u4ece\u672c\u5730\u7f13\u5b58\u4e2d\u83b7\u53d6\u6570\u636e\r\n&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;res&nbsp;=&nbsp;await&nbsp;wx.getStorage({&nbsp;key:&nbsp;'logs'&nbsp;});&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;logs&nbsp;=&nbsp;res.data&nbsp;||&nbsp;[];&nbsp;&nbsp;&nbsp;&nbsp;logs.unshift(Date.now());&nbsp;&nbsp;&nbsp;&nbsp;await&nbsp;wx.setStorage({&nbsp;key:&nbsp;'logs',&nbsp;data:&nbsp;logs&nbsp;});&nbsp;&nbsp;&nbsp;&nbsp;this.timer();\r\n&nbsp;&nbsp;}&nbsp;&nbsp;async&nbsp;timer()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(true)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log('hello');&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;await&nbsp;sleep(10000);\r\n&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;}&nbsp;&nbsp;async&nbsp;getUserInfo()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(this.globalData.userInfo)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;this.globalData.userInfo;\r\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;await&nbsp;wx.login();&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;res&nbsp;=&nbsp;await&nbsp;wx.getUserInfo();&nbsp;&nbsp;&nbsp;&nbsp;this.globalData.userInfo&nbsp;=&nbsp;res.userInfo;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;res.userInfo;\r\n&nbsp;&nbsp;}\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee3\u7801\u4e2d\u5168\u90e8\u4f7f\u7528ES6\/7\u6807\u51c6\u8bed\u6cd5\u3002\u4ee3\u7801\u4e0d\u5fc5\u58f0\u660e&nbsp;use strict&nbsp;\uff0c\u56e0\u4e3a\u5728\u7f16\u8bd1\u65f6\uff0c\u6240\u6709\u4ee3\u7801\u90fd\u4f1a\u5f3a\u5236\u4f7f\u7528\u4e25\u683c\u6a21\u5f0f\u3002<\/p>\n<p>\u4ee3\u7801\u4e2d\u5e76\u672a\u8c03\u7528\u5168\u5c40\u7684&nbsp;App()&nbsp;\u65b9\u6cd5\uff0c\u800c\u662f\u4f7f\u7528&nbsp;export&nbsp;\u8bed\u6cd5\u9ed8\u8ba4\u5bfc\u51fa\u4e86\u4e00\u4e2a\u7c7b\uff0c\u5728\u7f16\u8bd1\u540e\uff0cLabrador\u4f1a\u81ea\u52a8\u589e\u52a0&nbsp;App()&nbsp;\u65b9\u6cd5\u8c03\u7528\uff0c\u6240\u6709\u8bf7\u52ff\u624b\u52a8\u8c03\u7528&nbsp;App()&nbsp;\u65b9\u6cd5\u3002\u8fd9\u6837\u505a\u662f\u56e0\u4e3a\u4ee3\u7801\u98ce\u683c\u4e0d\u5efa\u8bae\u7c97\u66b4\u5730\u8bbf\u95ee\u5168\u5c40\u5bf9\u8c61\u548c\u65b9\u6cd5\u3002<\/p>\n<p style=\"padding: 0px 0px 0.3em;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u81ea\u5b9a\u4e49\u7ec4\u4ef6<\/p>\n<p>Labrador\u7684\u81ea\u5b9a\u4e49\u7ec4\u4ef6\uff0c\u662f\u57fa\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6846\u67b6\u7684\u7ec4\u4ef6\u4e4b\u4e0a\uff0c\u8fdb\u4e00\u6b65\u81ea\u5b9a\u4e49\u7ec4\u5408\uff0c\u62e5\u6709\u903b\u8f91\u5904\u7406\u548c\u6837\u5f0f\u3002<\/p>\n<p>\u9879\u76ee\u4e2d\u901a\u7528\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5b58\u653e\u5728&nbsp;src\/compontents&nbsp;\u76ee\u5f55\uff0c\u4e00\u4e2a\u7ec4\u4ef6\u4e00\u822c\u7531\u4e09\u4e2a\u6587\u4ef6\u7ec4\u6210\uff0c*.js&nbsp;\u3001&nbsp;*.xml&nbsp;\u548c&nbsp;*.less&nbsp;\u5206\u522b\u5bf9\u5e94\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6846\u67b6\u7684&nbsp;js&nbsp;\u3001&nbsp;wxml&nbsp;\u548c&nbsp;wxss&nbsp;\u6587\u4ef6\u3002\u5728Labardor\u9879\u76ee\u6e90\u7801\u4e2d\uff0c\u6211\u4eec\u7279\u610f\u91c7\u7528\u4e86&nbsp;xml&nbsp;\u548c&nbsp;less&nbsp;\u540e\u7f00\u4ee5\u793a\u533a\u522b\u3002\u5982\u679c\u7ec4\u4ef6\u5305\u542b\u5355\u5143\u6d4b\u8bd5\uff0c\u90a3\u4e48\u5728\u7ec4\u4ef6\u76ee\u5f55\u4e0b\u4f1a\u5b58\u5728\u4e00\u4e2a&nbsp;*.test.js&nbsp;\u7684\u6d4b\u8bd5\u811a\u672c\u6587\u4ef6\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u793a\u4f8b<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u4ee3\u7801\u5b9e\u4f8b\uff1a<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;font-size: 0.875em;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u903b\u8f91&nbsp;src\/compontents\/title\/title.js<\/p>\n<pre>import&nbsp;wx&nbsp;from&nbsp;'labrador';import&nbsp;randomColor&nbsp;&nbsp;from&nbsp;'..\/..\/utils\/random-color';const&nbsp;{&nbsp;string&nbsp;}&nbsp;=&nbsp;wx.PropTypes;export&nbsp;default&nbsp;class&nbsp;Title&nbsp;extends&nbsp;wx.Component&nbsp;{\r\n\r\n&nbsp;&nbsp;propTypes&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;text:&nbsp;string\r\n&nbsp;&nbsp;};\r\n\r\n&nbsp;&nbsp;props&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;text:&nbsp;''\r\n&nbsp;&nbsp;};\r\n\r\n&nbsp;&nbsp;data&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;text:&nbsp;'',\r\n&nbsp;&nbsp;&nbsp;&nbsp;color:&nbsp;randomColor()\r\n&nbsp;&nbsp;};&nbsp;&nbsp;onUpdate(props)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;this.setData('text',&nbsp;props.text);\r\n&nbsp;&nbsp;}&nbsp;&nbsp;handleTap()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;this.setData({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color:&nbsp;randomColor()\r\n&nbsp;&nbsp;&nbsp;&nbsp;});\r\n&nbsp;&nbsp;}\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7684\u903b\u8f91\u4ee3\u7801\u548c\u5fae\u4fe1\u6846\u67b6\u4e2d\u7684page\u5f88\u76f8\u4f3c\uff0c\u6700\u5927\u7684\u533a\u522b\u662f\u5728js\u903b\u8f91\u4ee3\u7801\u4e2d\uff0c\u6ca1\u6709\u8c03\u7528\u5168\u5c40\u7684&nbsp;Page()&nbsp;\u51fd\u6570\u58f0\u660e\u9875\u9762\uff0c\u800c\u662f\u7528&nbsp;export&nbsp;\u8bed\u6cd5\u5bfc\u51fa\u4e86\u4e00\u4e2a\u9ed8\u8ba4\u7684\u7c7b\uff0c\u8fd9\u4e2a\u7c7b\u5fc5\u987b\u7ee7\u627f\u4e8e&nbsp;labrador.Component&nbsp;\u7ec4\u4ef6\u57fa\u7c7b\u3002<\/p>\n<p>\u76f8\u5bf9\u4e8e\u5fae\u4fe1\u6846\u67b6\u4e2d\u7684page\uff0cLabrador\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u6269\u5c55\u4e86&nbsp;propTypes&nbsp;\u3001&nbsp;props&nbsp;\u3001&nbsp;children&nbsp;\u9009\u9879\u53ca&nbsp;onUpdate&nbsp;\u751f\u547d\u5468\u671f\u51fd\u6570\u3002children&nbsp;\u9009\u9879\u4ee3\u8868\u5f53\u524d\u7ec4\u4ef6\u4e2d\u7684\u5b50\u7ec4\u4ef6\u96c6\u5408\uff0c\u6b64\u9009\u9879\u5c06\u5728\u4e0b\u6587\u4e2d\u53d9\u8ff0\u3002<\/p>\n<p>Labrador\u7684\u76ee\u6807\u662f\u6784\u5efa\u4e00\u4e2a\u53ef\u4ee5\u91cd\u7528\u3001\u5d4c\u5957\u7684\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u65b9\u6848\uff0c\u5728\u73b0\u5b9e\u60c5\u51b5\u4e2d\uff0c\u5f53\u591a\u4e2a\u7ec4\u4ef6\u4e92\u76f8\u5d4c\u5957\u7ec4\u5408\uff0c\u5c31\u4e00\u5b9a\u4f1a\u9047\u5230\u7236\u5b50\u7ec4\u4ef6\u4ef6\u7684\u6570\u636e\u548c\u6d88\u606f\u4f20\u9012\u3002\u56e0\u4e3a\u6240\u6709\u7684\u7ec4\u4ef6\u90fd\u5b9e\u73b0\u4e86&nbsp;setData&nbsp;\u65b9\u6cd5\uff0c\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528this.children.foobar.setData(data)&nbsp;\u6216&nbsp;this.parent.setData(data)&nbsp;\u8fd9\u6837\u7684\u4ee3\u7801\u8c03\u7528\u6765\u89e3\u51b3\u7236\u5b50\u7ec4\u4ef6\u95f4\u7684\u6570\u636e\u4f20\u9012\u95ee\u9898\uff0c\u4f46\u662f\uff0c\u5982\u679c\u9879\u76ee\u4e2d\u51fa\u73b0\u5927\u91cf\u8fd9\u6837\u7684\u4ee3\u7801\uff0c\u90a3\u4e48\u6570\u636e\u6d41\u5c06\u53d8\u5f97\u975e\u5e38\u6df7\u4e71\u3002<\/p>\n<p>\u6211\u4eec\u501f\u9274\u4e86 React.js \u7684\u601d\u60f3\uff0c\u4e3a\u7ec4\u4ef6\u589e\u52a0\u4e86 props \u673a\u5236\u3002\u5b50\u7ec4\u4ef6\u901a\u8fc7&nbsp;this.props&nbsp;\u5f97\u5230\u7236\u7ec4\u4ef6\u7ed9\u81ea\u5df1\u4f20\u8fbe\u7684\u53c2\u6570\u6570\u636e\u3002\u7236\u7ec4\u4ef6\u600e\u6837\u5c06\u6570\u636e\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6\uff0c\u6211\u4eec\u4e0b\u6587\u4e2d\u53d9\u8ff0\u3002<\/p>\n<p>onUpdate&nbsp;\u751f\u547d\u5468\u671f\u51fd\u6570\u662f\u5f53\u7ec4\u4ef6\u7684&nbsp;props&nbsp;\u53d1\u751f\u53d8\u5316\u540e\u88ab\u8c03\u7528\uff0c\u7c7b\u4f3cReact.js\u4e2d\u7684&nbsp;componentWillReceiveProps&nbsp;\u6240\u4ee5\u6211\u4eec\u53ef\u4ee5\u5728\u6b64\u51fd\u6570\u4f53\u5185\u76d1\u6d4b&nbsp;props&nbsp;\u7684\u53d8\u5316\u3002<\/p>\n<p>\u7ec4\u4ef6\u5b9a\u4e49\u65f6\u7684&nbsp;propTypes&nbsp;\u9009\u9879\u662f\u5bf9\u5f53\u524d\u7ec4\u4ef6\u7684props\u53c2\u6570\u6570\u636e\u7c7b\u578b\u7684\u5b9a\u4e49\u3002&nbsp;props&nbsp;\u9009\u9879\u4ee3\u8868\u7684\u662f\u5f53\u524d\u7ec4\u4ef6\u9ed8\u8ba4\u7684\u5404\u9879\u53c2\u6570\u503c\u3002propTypes&nbsp;\u3001&nbsp;props&nbsp;\u9009\u9879\u90fd\u53ef\u4ee5\u7701\u7565\uff0c\u4f46\u662f\u5f3a\u70c8\u5efa\u8bae\u5b9a\u4e49&nbsp;propTypes\uff0c\u56e0\u4e3a\u8fd9\u6837\u53ef\u4ee5\u4f7f\u5f97\u4ee3\u7801\u66f4\u6e05\u6670\u6613\u61c2\uff0c\u53e6\u5916\u8fd8\u53ef\u4ee5\u901a\u8fc7Labrador\u81ea\u52a8\u68c0\u6d4bprops\u503c\u7c7b\u578b\uff0c\u4ee5\u51cf\u5c11BUG\u3002\u4e3a\u4f18\u5316\u6027\u80fd\uff0c\u53ea\u6709\u5728DEBUG\u6a21\u5f0f\u4e0b\u624d\u4f1a\u81ea\u52a8\u68c0\u6d4bprops\u503c\u7c7b\u578b\u3002<\/p>\n<p>\u7f16\u8bd1\u65f6\u52a0\u4e0a&nbsp;-d&nbsp;\u53c2\u6570\u65f6\u5373\u53ef\u8fdb\u5165DEBUG\u6a21\u5f0f\uff0c\u5728\u4ee3\u7801\u4e2d\u4efb\u4f55\u5730\u65b9\u90fd\u53ef\u4ee5\u4f7f\u7528\u9b54\u672f\u53d8\u91cf&nbsp;__DEBUG__&nbsp;\u6765\u5224\u65ad\u662f\u5426\u662fDEBUG\u6a21\u5f0f\u3002<\/p>\n<p>\u53e6\u5916\uff0cLabrador\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7684&nbsp;setData&nbsp;\u65b9\u6cd5\uff0c\u652f\u6301\u4e24\u79cd\u4f20\u53c2\u65b9\u5f0f\uff0c\u7b2c\u4e00\u79cd\u50cf\u5fae\u4fe1\u6846\u67b6\u4e00\u6837\u63a5\u53d7\u4e00\u4e2a&nbsp;object&nbsp;\u7c7b\u578b\u7684\u5bf9\u8c61\u53c2\u6570\uff0c\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u63a5\u53d7\u4f5c\u4e3aKV\u5bf9\u7684\u4e24\u4e2a\u53c2\u6570\uff0csetData&nbsp;\u65b9\u6cd5\u5c06\u81ea\u52a8\u5c06\u5176\u8f6c\u4e3a&nbsp;object\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;font-size: 0.875em;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u5e03\u5c40&nbsp;src\/compontents\/title\/title.xml<\/p>\n<pre>&lt;view&gt;\r\n&nbsp;&nbsp;&lt;text&gt;{{text}}&lt;\/text&gt;&lt;\/view&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>XML\u5e03\u5c40\u6587\u4ef6\u548c\u5fae\u4fe1WXML\u6587\u4ef6\u8bed\u6cd5\u5b8c\u5168\u4e00\u81f4\uff0c\u53ea\u662f\u6269\u5145\u4e86\u4e24\u4e2a\u81ea\u5b9a\u4e49\u6807\u7b7e&nbsp; &nbsp;\u548c&nbsp; \uff0c\u4e0b\u6587\u4e2d\u8be6\u7ec6\u53d9\u8ff0\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;font-size: 0.875em;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u6837\u5f0f&nbsp;src\/compontents\/title\/title.less<\/p>\n<pre>.title-text&nbsp;{&nbsp;&nbsp;font-weight:&nbsp;bold;&nbsp;&nbsp;font-size:&nbsp;2em;\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u867d\u7136\u6211\u4eec\u91c7\u7528\u4e86LESS\u6587\u4ef6\uff0c\u4f46\u662f\u7531\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u6846\u67b6\u7684\u9650\u5236\uff0c\u4e0d\u80fd\u4f7f\u7528LESS\u7684\u5c42\u7ea7\u9009\u62e9\u53ca\u5d4c\u5957\u8bed\u6cd5\u3002\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528LESS\u7684\u53d8\u91cf\u3001mixin\u3001\u51fd\u6570\u7b49\u529f\u80fd\u65b9\u4fbf\u5f00\u53d1\u3002<\/p>\n<p style=\"padding: 0px 0px 0.3em;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u9875\u9762<\/p>\n<p>\u6211\u4eec\u8981\u6c42\u6240\u6709\u7684\u9875\u9762\u5fc5\u987b\u5b58\u653e\u5728&nbsp;pages&nbsp;\u76ee\u5f55\u4e2d\uff0c\u6bcf\u4e2a\u9875\u9762\u7684\u5b50\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u683c\u5f0f\u548c\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u4e00\u81f4\uff0c\u53ea\u662f\u53ef\u4ee5\u591a\u51fa\u4e00\u4e2a*.json&nbsp;\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u9875\u9762\u793a\u4f8b<\/p>\n<p>\u4e0b\u9762\u662f\u9ed8\u8ba4\u9996\u9875\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;font-size: 0.875em;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u903b\u8f91&nbsp;src\/pages\/index\/index.js<\/p>\n<pre>import&nbsp;wx&nbsp;from&nbsp;'labrador';import&nbsp;List&nbsp;from&nbsp;'..\/..\/components\/list\/list';import&nbsp;Title&nbsp;from&nbsp;'..\/..\/components\/title\/title';import&nbsp;Counter&nbsp;from&nbsp;'..\/..\/components\/counter\/counter';export&nbsp;default&nbsp;class&nbsp;Index&nbsp;extends&nbsp;wx.Component&nbsp;{\r\n&nbsp;&nbsp;data&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;userInfo:&nbsp;{},\r\n&nbsp;&nbsp;&nbsp;&nbsp;mottoTitle:&nbsp;'Hello&nbsp;World',\r\n&nbsp;&nbsp;&nbsp;&nbsp;count:&nbsp;0\r\n&nbsp;&nbsp;};\r\n\r\n&nbsp;&nbsp;children&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;list:&nbsp;new&nbsp;List(),\r\n&nbsp;&nbsp;&nbsp;&nbsp;motto:&nbsp;new&nbsp;Title({&nbsp;text:&nbsp;'@mottoTitle',&nbsp;hello:&nbsp;'@mottoTitle'&nbsp;}),\r\n&nbsp;&nbsp;&nbsp;&nbsp;counter:&nbsp;new&nbsp;Counter({&nbsp;count:&nbsp;'@count',&nbsp;onChange:&nbsp;'#handleCountChange'&nbsp;})\r\n&nbsp;&nbsp;};&nbsp;&nbsp;handleCountChange(count)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;this.setData({&nbsp;count&nbsp;});\r\n&nbsp;&nbsp;}&nbsp;&nbsp;\/\/\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\r\n&nbsp;&nbsp;handleViewTap()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;wx.navigateTo({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;url:&nbsp;'..\/logs\/logs'\r\n&nbsp;&nbsp;&nbsp;&nbsp;});\r\n&nbsp;&nbsp;}&nbsp;&nbsp;async&nbsp;onLoad()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;try&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u8c03\u7528\u5e94\u7528\u5b9e\u4f8b\u7684\u65b9\u6cd5\u83b7\u53d6\u5168\u5c40\u6570\u636e\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;userInfo&nbsp;=&nbsp;await&nbsp;wx.app.getUserInfo();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u66f4\u65b0\u6570\u636e\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.setData({&nbsp;userInfo&nbsp;});&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.update();\r\n&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;catch&nbsp;(error)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.error(error.stack);\r\n&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;}&nbsp;&nbsp;onReady()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;this.setData('mottoTitle',&nbsp;'Labrador');\r\n&nbsp;&nbsp;}\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u9875\u9762\u4ee3\u7801\u7684\u683c\u5f0f\u548c\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7684\u683c\u5f0f\u4e00\u6a21\u4e00\u6837\uff0c\u6211\u4eec\u7684\u601d\u60f3\u662f&nbsp;\u9875\u9762\u4e5f\u662f\u7ec4\u4ef6\u3002<\/p>\n<p>js\u903b\u8f91\u4ee3\u7801\u4e2d\u540c\u6837\u4f7f\u7528&nbsp;export default&nbsp;\u8bed\u53e5\u5bfc\u51fa\u4e86\u4e00\u4e2a\u9ed8\u8ba4\u7c7b\uff0c\u4e5f\u4e0d\u80fd\u624b\u52a8\u8c03\u7528&nbsp;Page()&nbsp;\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5728\u7f16\u8bd1\u540e\uff0cpages&nbsp;\u76ee\u5f55\u4e0b\u7684\u6240\u6709js\u6587\u4ef6\u5168\u90e8\u4f1a\u81ea\u52a8\u8c03\u7528&nbsp;Page()&nbsp;\u65b9\u6cd5\u58f0\u660e\u9875\u9762\u3002<\/p>\n<p>\u6211\u4eec\u770b\u5230\u7ec4\u4ef6\u7c7b\u4e2d\uff0c\u6709\u4e00\u4e2a\u5bf9\u8c61\u5c5e\u6027&nbsp;children&nbsp;\uff0c\u8fd9\u4e2a\u5c5e\u6027\u5b9a\u4e49\u4e86\u8be5\u7ec4\u4ef6\u4f9d\u8d56\u3001\u5305\u542b\u7684\u5176\u4ed6\u81ea\u5b9a\u4e49\u7ec4\u4ef6\uff0c\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\u9875\u9762\u5305\u542b\u4e86\u4e09\u4e2a\u81ea\u5b9a\u4e49\u7ec4\u4ef6&nbsp;list&nbsp;\u3001&nbsp;title&nbsp;\u548c&nbsp;counter&nbsp;\uff0c\u8fd9\u4e2a\u4e09\u4e2a\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7684&nbsp;key&nbsp;\u5206\u522b\u4e3a&nbsp;list&nbsp;\u3001&nbsp;motto&nbsp;\u548c&nbsp;counter\u3002<\/p>\n<p>\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7c7b\u5728\u5b9e\u4f8b\u5316\u65f6\u63a5\u53d7\u4e00\u4e2a\u7c7b\u578b\u4e3a&nbsp;object&nbsp;\u7684\u53c2\u6570\uff0c\u8fd9\u4e2a\u53c2\u6570\u5c31\u662f\u7236\u7ec4\u4ef6\u8981\u4f20\u7ed9\u5b50\u7ec4\u4ef6\u7684props\u6570\u636e\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7236\u7ec4\u4ef6\u4f20\u9012\u7ed9\u5b50\u7ec4\u4ef6\u7684props\u5c5e\u6027\u5728\u5176\u751f\u547d\u5468\u671f\u4e2d\u662f\u4e0d\u53d8\u7684\uff0c\u8fd9\u662f\u56e0\u4e3aJS\u7684\u8bed\u6cd5\u548c\u5c0f\u7a0b\u5e8f\u6846\u67b6\u7684\u9650\u5236\uff0c\u6ca1\u6709React.js\u7684JSX\u7075\u6d3b\u3002\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u4f20\u9012\u4e00\u4e2a\u4ee5&nbsp;@&nbsp;\u5f00\u5934\u7684\u5c5e\u6027\u503c\uff0c\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u628a\u5b50\u7ec4\u5efa\u7684&nbsp;props&nbsp;\u5c5e\u6027\u503c\u7ed1\u5b9a\u5230\u7236\u7ec4\u4ef6\u7684&nbsp;data&nbsp;\u4e0a\u6765\uff0c\u5f53\u7236\u7ec4\u4ef6\u7684data&nbsp;\u53d1\u751f\u53d8\u5316\u540e\uff0cLabrador\u5c06\u81ea\u52a8\u66f4\u65b0\u5b50\u7ec4\u4ef6\u7684&nbsp;props\u3002\u4f8b\u5982\u4e0a\u8fb9\u4ee3\u7801\u4e2d\uff0c\u5c06\u5b50\u7ec4\u4ef6&nbsp;motto&nbsp;\u7684&nbsp;text&nbsp;\u5c5e\u6027\u7ed1\u5b9a\u5230\u4e86@mottoTitle\u3002\u90a3\u4e48\u5728&nbsp;onReady&nbsp;\u65b9\u6cd5\u4e2d\uff0c\u5c06\u7236\u7ec4\u4ef6\u7684&nbsp;mottoTitle&nbsp;\u8bbe\u7f6e\u4e3a&nbsp;Labrador\uff0c\u90a3\u4e48\u5b50\u7ec4\u4ef6&nbsp;motto&nbsp;\u7684&nbsp;text&nbsp;\u5c5e\u6027\u5c31\u4f1a\u81ea\u52a8\u53d8\u4e3a&nbsp;Labrador\u3002\u5982\u679c\u5c5e\u6027\u503c\u4ee5&nbsp;#&nbsp;\u5f00\u5934\uff0c\u5219\u5c06\u7236\u7ec4\u4ef6\u7684\u5c5e\u6027\uff08\u975edata\u7684\u5c5e\u6027\uff09\u76f4\u63a5\u7ed1\u5b9a\u5230\u5b50\u7ec4\u4ef6&nbsp;props\uff0c\u5982\u4e0a\u8fb9\u4ee3\u7801\u4e2d\u7684&nbsp;#handleCountChange\uff0c\u4f1a\u5c06\u7236\u7ec4\u4ef6\u7684&nbsp;handleCountChange&nbsp;\u65b9\u6cd5\u7ed1\u5b9a\u5230\u5b50\u7ec4\u4ef6\u7684&nbsp;props.onChange&nbsp;\u5c5e\u6027\uff0c\u8fd9\u6837\u5b50\u7ec4\u4ef6\u4e2d\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528&nbsp;this.props.onChange(newValue)&nbsp;\u6765\u901a\u77e5\u7236\u7ec4\u4ef6\u6570\u636e\u53d8\u5316\u3002<\/p>\n<p>\u9875\u9762\u4e5f\u662f\u7ec4\u4ef6\uff0c\u6240\u6709\u7684\u7ec4\u4ef6\u90fd\u62e5\u6709\u4e00\u6837\u7684\u751f\u547d\u5468\u671f\u51fd\u6570onLoad, onReady, onShow, onHide, onUnload\uff0conUpdate \u4ee5\u53casetData\u51fd\u6570\u3002<\/p>\n<p>componets&nbsp;\u548c&nbsp;pages&nbsp;\u4e24\u4e2a\u76ee\u5f55\u7684\u533a\u522b\u5728\u4e8e\uff0ccomponets&nbsp;\u4e2d\u5b58\u653e\u7684\u7ec4\u4ef6\u80fd\u591f\u88ab\u667a\u80fd\u52a0\u8f7d\uff0cpages&nbsp;\u76ee\u5f55\u4e2d\u7684\u7ec4\u4ef6\u5728\u7f16\u8bd1\u65f6\u81ea\u52a8\u52a0\u4e0a&nbsp;Page()&nbsp;\u8c03\u7528\uff0c\u6240\u4ee5\uff0cpages&nbsp;\u76ee\u5f55\u4e2d\u7684\u7ec4\u4ef6\u4e0d\u80fd\u88ab\u5176\u4ed6\u7ec4\u4ef6\u8c03\u7528,\u5426\u5219\u5c06\u51fa\u73b0\u591a\u6b21\u8c03\u7528Page()\u7684\u9519\u8bef\u3002\u5982\u679c\u67d0\u4e2a\u7ec4\u4ef6\u9700\u8981\u91cd\u7528\uff0c\u8bf7\u5b58\u653e\u5728&nbsp;componets&nbsp;\u76ee\u5f55\u6216\u6253\u5305\u6210NPM\u5305\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;font-size: 0.875em;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u5e03\u5c40&nbsp;src\/pages\/index\/index.xml<\/p>\n<pre>&lt;view&gt;\r\n&nbsp;&nbsp;&lt;view&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;image&gt;&lt;\/image&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;text&gt;{{&nbsp;userInfo.nickName&nbsp;}}&lt;\/text&gt;\r\n&nbsp;&nbsp;&lt;\/view&gt;\r\n&nbsp;&nbsp;&lt;view&gt;\r\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;component&gt;&lt;\/component&gt;\r\n&nbsp;&nbsp;&lt;\/view&gt;\r\n&nbsp;&nbsp;&lt;component&gt;&lt;\/component&gt;\r\n&nbsp;&nbsp;&lt;component&gt;&lt;\/component&gt;&lt;\/view&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>XML\u5e03\u5c40\u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528\u4e86Labrador\u63d0\u4f9b\u7684&nbsp; &nbsp;\u6807\u7b7e\uff0c\u6b64\u6807\u7b7e\u7684\u4f5c\u7528\u662f\u5bfc\u5165\u4e00\u4e2a\u81ea\u5b9a\u4e49\u5b50\u7ec4\u4ef6\u7684\u5e03\u5c40\u6587\u4ef6\uff0c\u6807\u7b7e\u6709\u4e24\u4e2a\u5c5e\u6027\uff0c\u5206\u522b\u4e3a&nbsp;key&nbsp;(\u5fc5\u9009)\u548c&nbsp;name&nbsp;(\u53ef\u9009\uff0c\u9ed8\u8ba4\u4e3akey\u7684\u503c)\u3002key&nbsp;\u4e0ejs\u903b\u8f91\u4ee3\u7801\u4e2d\u7684\u7ec4\u4ef6&nbsp;key&nbsp;\u5bf9\u5e94\uff0cname&nbsp;\u662f\u7ec4\u4ef6\u7684\u76ee\u5f55\u540d\u3002key&nbsp;\u7528\u6765\u7ed1\u5b9a\u7ec4\u4ef6JS\u903b\u8f91\u5bf9\u8c61\u7684&nbsp;children&nbsp;\u4e2d\u5bf9\u5e94\u7684\u6570\u636e\uff0c&nbsp;name&nbsp;\u7528\u4e8e\u5728src\/componets&nbsp;\u548c&nbsp;node_modules&nbsp;\u76ee\u5f55\u4e2d\u5bfb\u627e\u5b50\u7ec4\u4ef6\u6a21\u677f\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;font-size: 0.875em;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u6837\u5f0f&nbsp;src\/pages\/index\/index.less<\/p>\n<pre>@import&nbsp;'list';@import&nbsp;'title';@import&nbsp;'counter';.motto-title-text&nbsp;{&nbsp;&nbsp;font-size:&nbsp;3em;&nbsp;&nbsp;padding-bottom:&nbsp;1rem;\r\n}\/*&nbsp;...&nbsp;*\/<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>LESS\u6837\u5f0f\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86&nbsp;@import&nbsp;\u8bed\u53e5\u52a0\u8f7d\u6240\u6709\u5b50\u7ec4\u4ef6\u6837\u5f0f\uff0c\u8fd9\u91cc\u7684&nbsp;@import &#8216;list&#8217;&nbsp;\u8bed\u53e5\u6309\u7167LESS\u7684\u8bed\u6cd5\uff0c\u4f1a\u9996\u5148\u5bfb\u627e\u5f53\u524d\u76ee\u5f55&nbsp;src\/pages\/index\/&nbsp;\u4e2d\u7684&nbsp;list.less&nbsp;\u6587\u4ef6\uff0c\u5982\u679c\u627e\u4e0d\u5230\u5c31\u4f1a\u6309\u7167Labrador\u7684\u89c4\u5219\u667a\u80fd\u5730\u5c1d\u8bd5\u5bfb\u627e&nbsp;src\/componets\u548c&nbsp;node_modules&nbsp;\u76ee\u5f55\u4e2d\u7684\u7ec4\u4ef6\u6837\u5f0f\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86&nbsp;.motto-title-text&nbsp;\u6837\u5f0f\uff0c\u8fd9\u6837\u505a\u662f\u56e0\u4e3a&nbsp;motto&nbsp;key \u4ee3\u8868\u7684title\u7ec4\u4ef6\u7684\u6a21\u677f\u4e2d\uff08src\/compontents\/title\/title.xml\uff09\u6709\u4e00\u4e2aview \u5c5e\u4e8e&nbsp;title-text&nbsp;\u7c7b\uff0c\u7f16\u8bd1\u65f6\uff0cLabrador\u5c06\u81ea\u52a8\u4e3a\u5176\u589e\u52a0\u4e00\u4e2a\u524d\u7f00motto-&nbsp;\uff0c\u6240\u4ee5\u7f16\u8bd1\u540e\u8fd9\u4e2aview\u6240\u5c5e\u7684\u7c7b\u4e3a&nbsp;title-text motto-title-text&nbsp;\uff08\u53ef\u4ee5\u67e5\u770b&nbsp;dist\/pages\/index\/index.xml\uff09\u3002\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u5728\u7236\u7ec4\u4ef6\u7684\u6837\u5f0f\u4ee3\u7801\u4e2d\u4f7f\u7528&nbsp;.motto-title-text&nbsp;\u6765\u91cd\u65b0\u5b9a\u4e49\u5b50\u7ec4\u4ef6\u7684\u6837\u5f0f\u3002<\/p>\n<p>Labrador\u652f\u6301\u591a\u5c42\u7ec4\u4ef6\u5d4c\u5957\uff0c\u5728\u4e0a\u8ff0\u7684\u5b9e\u4f8b\u4e2d\uff0cindex&nbsp;\u5305\u542b\u5b50\u7ec4\u4ef6&nbsp;list&nbsp;\u548c&nbsp;title\uff0clist&nbsp;\u5305\u542b\u5b50\u7ec4\u4ef6&nbsp;title\uff0c\u6240\u4ee5\u5728\u6700\u7ec8\u663e\u793a\u65f6\uff0cindex&nbsp;\u9875\u9762\u4e0a\u56de\u663e\u793a\u4e24\u4e2a&nbsp;title&nbsp;\u7ec4\u4ef6\u3002<\/p>\n<p>\u8be6\u7ec6\u4ee3\u7801\u8bf7\u53c2\u9605&nbsp;labrador init&nbsp;\u547d\u4ee4\u751f\u6210\u7684\u793a\u4f8b\u9879\u76ee\u3002<\/p>\n<p style=\"padding: 0px 0px 0.3em;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5217\u8868<\/p>\n<p>Labrador 0.5\u7248\u672c\u540e\u652f\u6301\u5faa\u73af\u8c03\u7528\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u751f\u6210\u4e00\u4e2a\u5217\u8868\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;font-size: 0.875em;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u903b\u8f91&nbsp;src\/components\/list\/list.js<\/p>\n<pre>import&nbsp;wx&nbsp;from&nbsp;'labrador';import&nbsp;Title&nbsp;from&nbsp;'..\/title\/title';import&nbsp;Item&nbsp;from&nbsp;'..\/item\/item';import&nbsp;{&nbsp;sleep&nbsp;}&nbsp;from&nbsp;'..\/..\/utils\/util';export&nbsp;default&nbsp;class&nbsp;List&nbsp;extends&nbsp;wx.Component&nbsp;{\r\n\r\n&nbsp;&nbsp;data&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;items:&nbsp;[\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;title:&nbsp;'Labrador'&nbsp;},\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;title:&nbsp;'Alaska'&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;]\r\n&nbsp;&nbsp;};\r\n\r\n&nbsp;&nbsp;children&nbsp;=&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;title:&nbsp;new&nbsp;Title({&nbsp;text:&nbsp;'The&nbsp;List&nbsp;Title'&nbsp;}),\r\n&nbsp;&nbsp;&nbsp;&nbsp;listItems:&nbsp;new&nbsp;wx.List(Item,&nbsp;'items',&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item:&nbsp;'&amp;gt;&amp;gt;',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;title:&nbsp;'&amp;gt;title',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isNew:&nbsp;'&amp;gt;isNew',\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;onChange:&nbsp;'#handleChange'\r\n&nbsp;&nbsp;&nbsp;&nbsp;})\r\n&nbsp;&nbsp;};&nbsp;&nbsp;async&nbsp;onLoad()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;await&nbsp;sleep(1000);&nbsp;&nbsp;&nbsp;&nbsp;this.setData({\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;items:&nbsp;[{&nbsp;title:&nbsp;'Collie',&nbsp;isNew:&nbsp;true&nbsp;}].concat(this.data.items)\r\n&nbsp;&nbsp;&nbsp;&nbsp;});\r\n&nbsp;&nbsp;}&nbsp;&nbsp;handleChange(component,&nbsp;title)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;item&nbsp;=&nbsp;this.data.items[component.key];&nbsp;&nbsp;&nbsp;&nbsp;item.title&nbsp;=&nbsp;title;&nbsp;&nbsp;&nbsp;&nbsp;this.setData('items',&nbsp;this.data.items);\r\n&nbsp;&nbsp;}\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u4e0a\u8fb9\u4ee3\u7801\u4e2d\u7684&nbsp;children.listItems&nbsp;\u5b50\u7ec4\u4ef6\u5b9a\u4e49\u65f6\uff0c\u5e76\u6ca1\u6709\u76f4\u63a5\u5b9e\u4f8b\u5316\u5b50\u7ec4\u4ef6\u7c7b\uff0c\u800c\u662f\u5b9e\u4f8b\u5316\u4e86\u4e00\u4e2a&nbsp;labrador.List&nbsp;\u7c7b\uff0c\u8fd9\u4e2a\u7c7b\u662fLabrador\u4e2d\u4e13\u95e8\u7528\u6765\u7ba1\u7406\u7ec4\u4ef6\u5217\u8868\u3002labrador.List&nbsp;\u5b9e\u4f8b\u5316\u65f6\uff0c\u63a5\u53d7\u4e09\u4e2a\u53c2\u6570\uff1a<\/p>\n<p>\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u5217\u8868\u4e2d\u7684\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7c7b\uff0c\u8bf7\u5c06\u539f\u59cb\u7c7b\u4f20\u5165\u5373\u53ef\uff0c\u4e0d\u7528\u5b9e\u4f8b\u5316\u3002<\/p>\n<p>\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u7236\u7ec4\u4ef6\u4e0a&nbsp;data&nbsp;\u5c5e\u6027\u6307\u5411\uff0c\u6307\u5411\u7684\u5c5e\u6027\u5fc5\u987b\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u4f8b\u5982\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u4e3a&nbsp;items&nbsp;\uff0c\u5219\u5f53\u524d\u7236\u7ec4\u4ef6\u7684&nbsp;data.items&nbsp;\u5c5e\u6027\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u8fd9\u4e2a\u6570\u7ec4\u53c8\u591a\u5c11\u4e2a\u5143\u7d20\uff0c\u90a3\u4e48\u5b50\u7ec4\u4ef6\u5217\u8868\u4e2d\u5c31\u81ea\u52a8\u4ea7\u751f\u591a\u5c11\u4e2a\u5b50\u7ec4\u4ef6\u3002\u5b50\u7ec4\u4ef6\u7684\u6570\u91cf\u8ddf\u968fdata.items&nbsp;\u6570\u7ec4\u52a8\u6001\u53d8\u5316\uff0cLabrador\u4f1a\u81ea\u52a8\u5b9e\u4f8b\u5316\u6216\u9500\u6bc1\u76f8\u5e94\u7684\u5b50\u7ec4\u4ef6\u3002\u9500\u6bc1\u5b50\u7ec4\u4ef6\u65f6\uff0c\u5b50\u7ec4\u4ef6\u7684&nbsp;onUnload()&nbsp;\u65b9\u6cd5\u5c06\u4f1a\u88ab\u8c03\u7528\u3002<\/p>\n<p>\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u5b50\u7ec4\u4ef6&nbsp;props&nbsp;\u6570\u636e\u7ed1\u5b9a\u8bbe\u7f6e\uff0c\u5982\u679c\u5c5e\u6027\u503c\u4ee5&nbsp;&gt;&nbsp;\u5f00\u5934\uff0c\u5219\u5c06&nbsp;data.items&nbsp;\u4e2d\u5bf9\u5e94\u5143\u7d20\u7684\u5c5e\u6027\u7ed1\u5b9a\u5230\u5b50\u7ec4\u4ef6\u7684props\u3002\u5982\u679c\u5c5e\u6027\u503c\u4ee5&nbsp;#&nbsp;\u5f00\u5934\uff0c\u5219\u5c06\u7236\u7ec4\u4ef6\u7684\u65b9\u6cd5\u7ed1\u5b9a\u5230\u5b50\u7ec4\u4ef6\u7684&nbsp;props&nbsp;\u4e2d\u3002\u6ce8\u610f\uff0c\u56e0\u4e3a\u5b50\u7ec4\u4ef6\u662f\u4e00\u4e2a\u5217\u8868\uff0c\u6240\u4ee5\u4e3a\u4e86\u533a\u522b\uff0c\u7236\u7ec4\u4ef6\u5bf9\u5e94\u7684\u65b9\u6cd5\u88ab\u8c03\u7528\u65f6\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u4e3a\u5b50\u7ec4\u4ef6\u7684\u5b9e\u4f8b\uff0c\u7b2c\u4e8c\u4e2a\u53ca\u5176\u4e4b\u540e\u7684\u53c2\u6570\u624d\u662f\u5b50\u7ec4\u4ef6\u4e2d\u4f20\u56de\u7684\u53c2\u6570\u3002\u5982\u679c\u5c5e\u6027\u503c\u662f&nbsp;&gt;&gt;&nbsp;\u5219\u5c06\u6574\u4e2a\u5217\u8868\u9879\u6570\u636e\u7ed1\u5b9a\u5230\u5bf9\u5e94\u7684&nbsp;props&nbsp;\u4e0a\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;font-size: 0.875em;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u6a21\u677f&nbsp;src\/components\/list\/list.xml<\/p>\n<pre>&lt;view&gt;\r\n&nbsp;&nbsp;&lt;component&gt;&lt;\/component&gt;\r\n&nbsp;&nbsp;&lt;list&gt;&lt;\/list&gt;&lt;\/view&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728XML\u6a21\u677f\u4e2d\uff0c\u8c03\u7528&nbsp; &nbsp;\u6807\u7b7e\u5373\u53ef\u81ea\u52a8\u6e32\u67d3\u5b50\u7ec4\u4ef6\u5217\u8868\u3002\u548c&nbsp; &nbsp;\u6807\u7b7e\u7c7b\u4f3c\uff0c &nbsp;\u540c\u6837\u4e5f\u6709\u4e24\u4e2a\u5c5e\u6027\uff0ckey&nbsp;\u548c&nbsp;name\u3002Labrador\u7f16\u8bd1\u540e\uff0c\u4f1a\u81ea\u52a8\u5c06&nbsp; &nbsp;\u6807\u7b7e\u7f16\u8bd1\u6210&nbsp;wx:for&nbsp;\u5faa\u73af\u3002<\/p>\n<p style=\"padding: 0px 0px 0.3em;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u81ea\u52a8\u5316\u6d4b\u8bd5<\/p>\n<p>\u6211\u4eec\u89c4\u5b9a\u9879\u76ee\u4e2d\u6240\u6709\u540e\u7f00\u4e3a&nbsp;*.test.js&nbsp;\u7684\u6587\u4ef6\u4e3a\u6d4b\u8bd5\u811a\u672c\u6587\u4ef6\u3002\u6bcf\u4e00\u4e2a\u6d4b\u8bd5\u811a\u672c\u6587\u4ef6\u5bf9\u5e94\u4e00\u4e2a\u5f85\u6d4b\u8bd5\u7684JS\u6a21\u5757\u6587\u4ef6\u3002\u4f8b\u5982src\/utils\/util.js&nbsp;\u548c&nbsp;src\/utils\/utils.test.js&nbsp;\u3002\u8fd9\u6837\uff0c\u9879\u76ee\u4e2d\u6240\u6709\u6a21\u5757\u548c\u5176\u6d4b\u8bd5\u6587\u4ef6\u5c31\u5168\u90e8\u5b58\u653e\u5728\u4e00\u8d77\uff0c\u65b9\u4fbf\u67e5\u627e\u548c\u6a21\u5757\u5212\u5206\u3002\u8fd9\u6837\u89c4\u5212\u4e3b\u8981\u662f\u53d7\u5230\u4e86GO\u8bed\u8a00\u7684\u542f\u53d1\uff0c\u4e5f\u7b26\u5408\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e00\u8d2f\u7684\u76ee\u5f55\u7ed3\u6784\u98ce\u683c\u3002<\/p>\n<p>\u5728\u7f16\u8bd1\u65f6\uff0c\u52a0\u4e0a&nbsp;-t&nbsp;\u53c2\u6570\u5373\u53ef\u81ea\u52a8\u8c03\u7528\u6d4b\u8bd5\u811a\u672c\u5b8c\u6210\u9879\u76ee\u6d4b\u8bd5\uff0c\u5982\u679c\u4e0d\u52a0&nbsp;-t&nbsp;\u53c2\u6570\uff0c\u5219\u6240\u6709\u6d4b\u8bd5\u811a\u672c\u4e0d\u4f1a\u88ab\u7f16\u8bd1\u5230&nbsp;dist&nbsp;\u76ee\u5f55\uff0c\u6240\u4ee5\u4e0d\u5fc5\u62c5\u5fc3\u9879\u76ee\u4f1a\u80a5\u80d6\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u666e\u901aJS\u6a21\u5757\u6d4b\u8bd5<\/p>\n<p>\u6d4b\u8bd5\u811a\u672c\u4e2d\u4f7f\u7528&nbsp;export&nbsp;\u8bed\u53e5\u5bfc\u51fa\u591a\u4e2a\u540d\u79f0\u4ee5&nbsp;test*&nbsp;\u5f00\u5934\u7684\u51fd\u6570\uff0c\u8fd9\u4e9b\u51fd\u6570\u5728\u8fd0\u884c\u540e\u4f1a\u88ab\u9010\u4e2a\u8c03\u7528\u5b8c\u6210\u6d4b\u8bd5\u3002\u5982\u679ctest\u6d4b\u8bd5\u51fd\u6570\u5728\u8fd0\u884c\u65f6\u629b\u51fa\u5f02\u5e38\uff0c\u5219\u89c6\u4e3a\u6d4b\u8bd5\u5931\u8d25\uff0c\u4f8b\u5982\u4ee3\u7801\uff1a<\/p>\n<pre>\/\/&nbsp;src\/util.js\/\/&nbsp;\u666e\u901a\u9879\u76ee\u6a21\u5757\u6587\u4ef6\u4e2d\u7684\u4ee3\u7801\u7247\u6bb5\uff0c\u5bfc\u51fa\u4e86\u4e00\u4e2a\u901a\u7528\u7684add\u51fd\u6570export&nbsp;function&nbsp;add(a,&nbsp;b)&nbsp;{&nbsp;&nbsp;return&nbsp;a&nbsp;+&nbsp;b;\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236    <\/p>\n<pre>\/\/&nbsp;src\/util.test.js\/\/&nbsp;\u6d4b\u8bd5\u811a\u672c\u6587\u4ef6\u4ee3\u7801\u7247\u6bb5import&nbsp;assert&nbsp;from&nbsp;'assert';\/\/\u6d4b\u8bd5&nbsp;util.add()&nbsp;\u51fd\u6570export&nbsp;function&nbsp;testAdd(exports)&nbsp;{&nbsp;&nbsp;assert(exports.add(1,&nbsp;1)&nbsp;===&nbsp;2);\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee3\u7801\u4e2d&nbsp;testAdd&nbsp;\u5373\u4e3a\u4e00\u4e2atest\u6d4b\u8bd5\u51fd\u6570\uff0c\u4e13\u95e8\u7528\u6765\u6d4b\u8bd5&nbsp;add()&nbsp;\u51fd\u6570\uff0c\u5728test\u51fd\u6570\u6267\u884c\u65f6\uff0c\u4f1a\u5c06\u76ee\u6807\u6a21\u5757\u4f5c\u4e3a\u53c2\u6570\u4f20\u8fdb\u6765\uff0c\u5373\u4f1a\u5c06&nbsp;util.js&nbsp;\u4e2d\u7684&nbsp;exports&nbsp;\u4f20\u8fdb\u6765\u3002<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u6d4b\u8bd5<\/p>\n<p>\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7684\u6d4b\u8bd5\u811a\u672c\u4e2d\u53ef\u4ee5\u5bfc\u51fa\u4e24\u7c7b\u6d4b\u8bd5\u51fd\u6570\u3002\u7b2c\u4e09\u7c7b\u548c\u666e\u901a\u6d4b\u8bd5\u811a\u672c\u4e00\u6837\uff0c\u4e5f\u4e3a&nbsp;test*&nbsp;\u51fd\u6570\uff0c\u4f46\u662f\u53c2\u6570\u4e0d\u662f&nbsp;exports&nbsp;\u800c\u662f\u8fd0\u884c\u4e2d\u7684\u3001\u5b9e\u4f8b\u5316\u540e\u7684\u7ec4\u4ef6\u5bf9\u8c61\u3002\u90a3\u4e48\u6211\u4eec\u5c31\u53ef\u4ee5\u5728test\u51fd\u6570\u4e2d\u8c03\u7528\u7ec4\u4ef6\u7684\u65b9\u6cd5\u6216\u5219\u8bbf\u95ee\u7ec4\u4ef6\u7684props&nbsp;\u548c&nbsp;data&nbsp;\u5c5e\u6027\uff0c\u6765\u6d4b\u8bd5\u884c\u4e3a\u3002\u53e6\u5916\uff0c\u666e\u901a\u6a21\u5757\u6d4b\u8bd5\u811a\u672c\u662f\u542f\u52a8\u540e\u5c31\u5f00\u59cb\u9010\u4e2a\u8fd0\u884c&nbsp;test*&nbsp;\u51fd\u6570\uff0c\u800c\u7ec4\u4ef6\u6d4b\u8bd5\u811a\u672c\u662f\u5f53\u7ec4\u4ef6&nbsp;onReady&nbsp;\u4ee5\u540e\u624d\u4f1a\u5f00\u59cb\u6d4b\u8bd5\u3002<\/p>\n<p>\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7684\u7b2c\u4e8c\u7c7b\u6d4b\u8bd5\u51fd\u6570\u662f\u4ee5&nbsp;on*&nbsp;\u5f00\u5934\uff0c\u548c\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u51fd\u6570\u540d\u79f0\u4e00\u6a21\u4e00\u6837\uff0c\u8fd9\u4e00\u7c7b\u6d4b\u8bd5\u51fd\u6570\u4e0d\u662f\u7b49\u5230\u7ec4\u4ef6&nbsp;onReady\u4ee5\u540e\u5f00\u59cb\u8fd0\u884c\uff0c\u800c\u662f\u5f53\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u51fd\u6570\u8fd0\u884c\u65f6\u88ab\u89e6\u53d1\u3002\u51fd\u6570\u63a5\u6536\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u4e3a\u7ec4\u4ef6\u7684\u5bf9\u8c61\u5f15\u7528\uff0c\u7b2c\u4e8c\u4e2a\u4e3arun&nbsp;\u51fd\u6570\u3002\u6bd4\u5982\u67d0\u4e2a\u7ec4\u4ef6\u6709\u4e00\u4e2a&nbsp;onLoad&nbsp;\u6d4b\u8bd5\u51fd\u6570\uff0c\u90a3\u4e48\u5f53\u7ec4\u4ef6\u5c06\u8981\u8fd0\u884c&nbsp;onLoad&nbsp;\u751f\u547d\u5468\u671f\u51fd\u6570\u65f6\uff0c\u5148\u89e6\u53d1&nbsp;onLoad&nbsp;\u6d4b\u8bd5\u51fd\u6570\uff0c\u5728\u6d4b\u8bd5\u51fd\u6570\u5185\u90e8\u8c03\u7528&nbsp;run()&nbsp;\u51fd\u6570\uff0c\u7ee7\u7eed\u6267\u884c\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u51fd\u6570\uff0crun()&nbsp;\u51fd\u6570\u8fd4\u56de\u7684\u6570\u636e\u5c31\u662f\u751f\u547d\u5468\u671f\u51fd\u6570\u8fd4\u56de\u7684\u6570\u636e\uff0c\u5982\u679c\u8fd4\u56de\u7684\u662fPromise\uff0c\u5219\u4ee3\u8868\u751f\u547d\u5468\u671f\u51fd\u6570\u662f\u4e00\u4e2a\u5f02\u6b65\u51fd\u6570\uff0c\u6d4b\u8bd5\u51fd\u6570\u4e5f\u53ef\u4ee5\u5199\u4e3aasync&nbsp;\u5f02\u6b65\u51fd\u6570\uff0c\u7b49\u5f85\u751f\u547d\u5468\u671f\u51fd\u6570\u7ed3\u675f\u3002\u8fd9\u6837\u6211\u4eec\u5c31\u53ef\u4ee5\u83b7\u53d6run()\u524d\u540e\u4e24\u4e2a\u72b6\u6001\u6570\u636e\uff0c\u6700\u540e\u5bf9\u6bd4\uff0c\u6765\u6d4b\u8bd5\u751f\u547d\u5468\u671f\u51fd\u6570\u7684\u8fd0\u884c\u662f\u5426\u6b63\u786e\u3002<\/p>\n<p>\u7b2c\u4e09\u7c7b\u6d4b\u8bd5\u51fd\u6570\u4e0e\u751f\u547d\u5468\u671f\u6d4b\u8bd5\u51fd\u6570\u7c7b\u4f3c\uff0c\u662f\u4ee5&nbsp;handle*&nbsp;\u5f00\u5934\uff0c\u7528\u4ee5\u6d4b\u8bd5\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u662f\u5426\u6b63\u786e\uff0c\u662f\u5728\u5bf9\u5e94\u4e8b\u4ef6\u53d1\u751f\u65f6\u8fd0\u884c\u6d4b\u8bd5\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>\/\/&nbsp;src\/components\/counter\/counter.test.jsexport&nbsp;function&nbsp;handleTap(c,&nbsp;run)&nbsp;{&nbsp;&nbsp;let&nbsp;num&nbsp;=&nbsp;c.data.num;&nbsp;&nbsp;run();&nbsp;&nbsp;let&nbsp;step&nbsp;=&nbsp;c.data.num&nbsp;-&nbsp;num;&nbsp;&nbsp;if&nbsp;(step&nbsp;!==&nbsp;1)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;Error('\u8ba1\u6570\u5668\u70b9\u51fb\u4e00\u6b21\u5e94\u8be5\u81ea\u589e1\uff0c\u4f46\u662f\u81ea\u589e\u4e86'&nbsp;+&nbsp;step);\r\n&nbsp;&nbsp;}\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u751f\u547d\u5468\u671f\u6d4b\u8bd5\u51fd\u6570\u548c\u4e8b\u4ef6\u6d4b\u8bd5\u51fd\u6570\u53ea\u4f1a\u6267\u884c\u4e00\u6b21\uff0c\u81ea\u52a8\u5316\u6d4b\u8bd5\u7684\u7ed3\u679c\u5c06\u4f1a\u8f93\u51fa\u5230Console\u63a7\u5236\u53f0\u3002<\/p>\n<p style=\"padding: 0px 0px 0.3em;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">\u9879\u76ee\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>labrador init&nbsp;\u547d\u4ee4\u5728\u521d\u59cb\u5316\u9879\u76ee\u65f6\uff0c\u4f1a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a&nbsp;.labrador&nbsp;\u9879\u76ee\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u679c\u4f60\u7684\u9879\u76ee\u662f\u4f7f\u7528 labrador-cli 0.3 \u7248\u672c\u521b\u5efa\u7684\uff0c\u53ef\u4ee5\u624b\u52a8\u589e\u52a0\u6b64\u6587\u4ef6\u3002<\/p>\n<p>\u914d\u7f6e\u6587\u4ef6\u4e3aJSON\u683c\u5f0f\uff0c\u9ed8\u8ba4\u914d\u7f6e\u4e3a\uff1a<\/p>\n<pre>{&nbsp;&nbsp;\"npmMap\":{\r\n&nbsp;&nbsp;},&nbsp;&nbsp;\"uglify\":{&nbsp;&nbsp;&nbsp;&nbsp;\"mangle\":&nbsp;[],&nbsp;&nbsp;&nbsp;&nbsp;\"compress\":&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\"warnings\":&nbsp;false\r\n&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;},&nbsp;&nbsp;\"classNames\":&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;\"for-test\":true\r\n&nbsp;&nbsp;}\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>npmMap&nbsp;\u5c5e\u6027\u4e3aNPM\u5305\u6620\u5c04\u8bbe\u7f6e\uff0c\u4f8b\u5982&nbsp;{&#8220;underscore&#8221;:&#8221;lodash&#8221;}&nbsp;\u914d\u7f6e\uff0c\u5982\u679c\u4f60\u7684\u6e90\u7801\u4e2d\u6709require(&#8216;underscore&#8217;)&nbsp;\u90a3\u4e48\u7f16\u8bd1\u540e\u5c06\u6210\u4e3a&nbsp;require(&#8216;lodash&#8217;)\u3002\u8fd9\u6837\u505a\u662f\u4e3a\u4e86\u89e3\u51b3\u5c0f\u7a0b\u5e8f\u7684\u73af\u5883\u9650\u5236\u5bfc\u81f4\u4e00\u4e9bNPM\u5305\u65e0\u6cd5\u4f7f\u7528\u7684\u95ee\u9898\u3002\u6bd4\u5982\u6211\u4eec\u7684\u4ee3\u7801\u5fc5\u987b\u4f9d\u8d56\u4e8e\u5305A\uff0cA\u53c8\u4f9d\u8d56\u4e8eB\uff0c\u5982\u679cB\u548c\u5c0f\u7a0b\u5e8f\u4e0d\u517c\u5bb9\uff0c\u5c06\u5bfc\u81f4A\u4e5f\u65e0\u6cd5\u4f7f\u7528\u3002\u5728\u8fd9\u603b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5Fork\u4e00\u4efdB\uff0c\u8d77\u540d\u4e3aC\uff0c\u5c06C\u4e2d\u4e0e\u5c0f\u7a0b\u5e8f\u4e0d\u517c\u5bb9\u7684\u4ee3\u7801\u8c03\u6574\u4e0b\uff0c\u6700\u540e\u5728\u9879\u76ee\u914d\u7f6e\u6587\u4ef6\u4e2d\u5c06B\u6620\u5c04\u4e3aC\uff0c\u90a3\u4e48\u5728\u7f16\u8bd1\u540e\u5c31\u4f1a\u7ed5\u8fc7B\u800c\u52a0\u8f7dC\uff0c\u4ece\u800c\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p>uglify&nbsp;\u5c5e\u6027\u4e3a UglifyJs2 \u7684\u538b\u7f29\u914d\u7f6e\uff0c\u5728\u7f16\u8bd1\u65f6\u9644\u52a0&nbsp;-m&nbsp;\u53c2\u6570\u5373\u53ef\u5bf9\u9879\u76ee\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u8fdb\u884c\u538b\u7f29\u5904\u7406\u3002<\/p>\n<p>classNames&nbsp;\u5c5e\u6027\u6307\u5b9a\u4e86\u4e0d\u538b\u7f29\u7684WXSS\u7c7b\u540d\uff0c\u5728\u538b\u7f29\u6a21\u5f0f\u4e0b\uff0c\u9ed8\u8ba4\u4f1a\u5c06\u6240\u6709WXSS\u7c7b\u540d\u538b\u7f29\u4e3a\u975e\u5e38\u77ed\u7684\u5b57\u7b26\u4e32\uff0c\u5e76\u629b\u5f03\u6240\u6709WXML\u9875\u9762\u4e2d\u672a\u66fe\u4f7f\u7528\u7684\u6837\u5f0f\u7c7b\uff0c\u5982\u679c\u6307\u5b9a\u4e86\u8be5\u914d\u7f6e\u9879\uff0c\u5219\u6307\u5b9a\u7684\u7c7b\u4e0d\u4f1a\u88ab\u538b\u7f29\u548c\u629b\u5f03\u3002\u8fd9\u4e2a\u914d\u7f6e\u5728\u52a8\u6001\u7c7b\u540d\u7684\u60c5\u51b5\u4e0b\u975e\u5e38\u5b9e\u7528\uff0c\u6bd4\u5982XML\u4e2dclass=&#8221;text-{{color}}&#8221;\uff0c\u5728\u7f16\u8bd1LESS\u65f6\uff0c\u65e0\u6cd5\u786e\u5b9aLESS\u4e2d\u7684.text-red\u7c7b\u662f\u5426\u88ab\u7528\u5230\uff0c\u6240\u4ee5\u9700\u8981\u914d\u7f6e\u6b64\u9879\u5f3a\u5236\u4fdd\u7559text-red\u7c7b\u3002<\/p>\n<p style=\"padding: 0px 0px 0.3em;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">ChangeLog<\/p>\n<p style=\"padding: 0px;margin: 24px 0px 16px;line-height: 1.25;font-family: -apple-system, BlinkMacSystemFont,\">2016-10-09<\/p>\n<p>labrador&nbsp;0.3.0<\/p>\n<p>\u91cd\u6784\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u652f\u6301\u7ed1\u5b9a\u5b50\u7ec4\u4ef6\u6570\u636e\u548c\u4e8b\u4ef6<\/p>\n<p>2016-10-12<\/p>\n<p>labrador&nbsp;0.4.0<\/p>\n<p>\u589e\u52a0\u81ea\u5b9a\u4e49\u7ec4\u4ef6props\u673a\u5236<\/p>\n<p>\u81ea\u52a8\u5316\u6d4b\u8bd5<\/p>\n<p>UglifyJS\u538b\u7f29\u96c6\u6210<\/p>\n<p>NPM\u5305\u6620\u5c04<\/p>\n<p>\u589e\u52a0.labrador\u9879\u76ee\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>2016-10-13<\/p>\n<p>labrador&nbsp;0.4.2<\/p>\n<p>\u4fee\u590d\u7ec4\u4ef6setData\u65b9\u6cd5\u4f18\u5316\u6027\u80fd\u4ea7\u751f\u7684\u6570\u636e\u4e0d\u540c\u6b65\u95ee\u9898<\/p>\n<p>\u5728DEBUG\u6a21\u5f0f\u4e0b\u8f93\u51fa\u8c03\u8bd5\u4fe1\u606f<\/p>\n<p>2016-10-16<\/p>\n<p>labrador&nbsp;0.5.0<\/p>\n<p>\u65b0\u589e\u7ec4\u4ef6\u5217\u8868<\/p>\n<p>\u91cd\u6784XML\u6a21\u677f\u7f16\u8bd1\u5668<\/p>\n<p>\u7f16\u8bd1\u65f6\u7ed1\u5b9a\u4e8b\u4ef6\u6539\u4e3a\u4e8b\u4ef6\u53d1\u751f\u65f6\u81ea\u52a8\u5206\u6d3e<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7ec4\u4ef6\u5316\u5f00\u53d1Labrador\u6846\u67b6\u7684\u4ecb\u7ecd\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>labrador \u547d\u4ee4 labrador init \u521d\u59cb\u5316\u9879\u76ee\u547d\u4ee4 \u6ce8\u610f\u6b64\u547d\u4ee4\u4f1a\u521d\u59cb\u5316\u5f53\u524d\u7684\u76ee\u5f55\u4e3a\u9879\u76ee\u76ee\u5f55\u3002 labrador build \u6784\u5efa\u5f53\u524d\u9879\u76ee &nbsp;&nbsp;Usage:&nbsp;labrador&nbsp;build&nbsp;[options] &nbsp;&nbsp;Options: &nbsp;&nbsp;&nbsp;&nbsp;-h,&nbsp;&#8211;help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output&nbsp;usage&nbsp;information &nbsp;&nbsp;&nbsp;&nbsp;-V,&nbsp;&#8211;version&nbsp;&nbsp;output&nbsp;the&nbsp;version&nbsp;number &nbsp;&nbsp;&nbsp;&nbsp;-c,&nbsp;&#8211;catch&nbsp;&nbsp;&nbsp;&nbsp;\u5728\u8f7d\u5165\u65f6\u81ea\u52a8catch\u6240\u6709JS\u811a\u672c\u7684\u9519\u8bef &nbsp;&nbsp;&nbsp;&nbsp;-t,&nbsp;&#8211;test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd0\u884c\u6d4b\u8bd5\u811a\u672c &nbsp;&nbsp;&nbsp;&nbsp;-d,&nbsp;&#8211;debug&nbsp;&nbsp;&nbsp;&nbsp;DEBUG\u6a21\u5f0f &nbsp;&nbsp;&nbsp;&nbsp;-m,&nbsp;&#8211;minify&nbsp;&nbsp;&nbsp;\u538b\u7f29\u4ee3\u7801 &nbsp;&nbsp;&nbsp;&nbsp;-f,&nbsp;&#8211;force&nbsp;&nbsp;&nbsp;&nbsp;\u5f3a\u5236\u6784\u5efa\uff0c\u4e0d\u4f7f\u7528\u7f13\u5b58 \u767b\u5f55\u540e\u590d\u5236 labrador watch \u76d1\u6d4b\u6587\u4ef6\u53d8\u5316 &nbsp;&nbsp;Usage:&nbsp;labrador&nbsp;watch&nbsp;[options] &nbsp;&nbsp;Options: &nbsp;&nbsp;&nbsp;&nbsp;-h,&nbsp;&#8211;help&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;output&nbsp;usage&nbsp;information &nbsp;&nbsp;&nbsp;&nbsp;-V,&nbsp;&#8211;version&nbsp;&nbsp;output&nbsp;the&nbsp;version&nbsp;number &nbsp;&nbsp;&nbsp;&nbsp;-c,&nbsp;&#8211;catch&nbsp;&nbsp;&nbsp;&nbsp;\u5728\u8f7d\u5165\u65f6\u81ea\u52a8catch\u6240\u6709JS\u811a\u672c\u7684\u9519\u8bef &nbsp;&nbsp;&nbsp;&nbsp;-t,&nbsp;&#8211;test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8fd0\u884c\u6d4b\u8bd5\u811a\u672c &nbsp;&nbsp;&nbsp;&nbsp;-d,&nbsp;&#8211;debug&nbsp;&nbsp;&nbsp;&nbsp;DEBUG\u6a21\u5f0f \u767b\u5f55\u540e\u590d\u5236 labrador \u5e93 labrador&nbsp;\u5e93\u5bf9\u5168\u5c40\u7684&nbsp;wx&nbsp;\u53d8\u91cf\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u5c06\u5927\u90e8\u5206&nbsp;wx&nbsp;\u5bf9\u8c61\u4e2d\u7684\u65b9\u6cd5\u8fdb\u884c\u4e86Promise\u652f\u6301\uff0c \u9664\u4e86\u4ee5&nbsp;on*&nbsp;\u5f00\u5934\u6216\u4ee5&nbsp;*Sync\u7ed3\u5c3e\u7684\u65b9\u6cd5\u3002\u5728\u5982\u4e0b\u4ee3\u7801\u4e2d\u4f7f\u7528&nbsp;labrador&nbsp;\u5e93\u3002 import&nbsp;wx&nbsp;from&nbsp;&#8216;labrador&#8217;;console.log(wx.version);wx.app;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/&nbsp;\u548c\u5168\u5c40\u7684&nbsp;getApp()&nbsp;\u51fd\u6570\u6548\u679c\u4e00\u6837\uff0c\u4ee3\u7801\u98ce\u683c\u4e0d\u5efa\u8bae\u7c97\u66b4\u5730\u8bbf\u95ee\u5168\u5c40\u5bf9\u8c61\u548c\u65b9\u6cd5wx.Component;&nbsp;&nbsp;&nbsp; \/\/&nbsp;Labrador&nbsp;\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u57fa\u7c7bwx.List;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/&nbsp;Labrador&nbsp;\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u5217\u8868\u7c7bwx.PropTypes;&nbsp;&nbsp;&nbsp; \/\/&nbsp;Labrador&nbsp;\u6570\u636e\u7c7b\u578b\u6821\u9a8c\u5668\u96c6\u5408wx.login;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/&nbsp;\u5c01\u88c5\u540e\u7684\u5fae\u4fe1\u767b\u5f55\u63a5\u53e3wx.getStorage;&nbsp;&nbsp; \/\/&nbsp;\u5c01\u88c5\u540e\u7684\u8bfb\u53d6\u7f13\u5b58\u63a5\u53e3 \u767b\u5f55\u540e\u590d\u5236 \u6211\u4eec\u5efa\u8bae\u4e0d\u8981\u518d\u4f7f\u7528&nbsp;wx.getStorageSync()&nbsp;\u7b49\u540c\u6b65\u963b\u585e\u65b9\u6cd5\uff0c\u800c\u5728&nbsp;async&nbsp;\u51fd\u6570\u4e2d\u4f7f\u7528&nbsp;await wx.getStorage()&nbsp;\u5f02\u6b65\u975e\u963b\u585e\u65b9\u6cd5\u63d0\u9ad8\u6027\u80fd\uff0c\u9664\u975e\u9047\u5230\u7279\u6b8a\u60c5\u51b5\u3002 app.js src\/app.js&nbsp;\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a import&nbsp;wx&nbsp;from&nbsp;&#8216;labrador&#8217;;import&nbsp;{sleep}&nbsp;from&nbsp;&#8216;.\/utils\/util&#8217;;export&nbsp;default&nbsp;class&nbsp;{ &nbsp;&nbsp;globalData&nbsp;=&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;userInfo:&nbsp;null &nbsp;&nbsp;};&nbsp;&nbsp;async&nbsp;onLaunch()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;\/\/\u8c03\u7528API\u4ece\u672c\u5730\u7f13\u5b58\u4e2d\u83b7\u53d6\u6570\u636e &nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;res&nbsp;=&nbsp;await&nbsp;wx.getStorage({&nbsp;key:&nbsp;&#8216;logs&#8217;&nbsp;});&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;logs&nbsp;=&nbsp;res.data&nbsp;||&nbsp;[];&nbsp;&nbsp;&nbsp;&nbsp;logs.unshift(Date.now());&nbsp;&nbsp;&nbsp;&nbsp;await&nbsp;wx.setStorage({&nbsp;key:&nbsp;&#8216;logs&#8217;,&nbsp;data:&nbsp;logs&nbsp;});&nbsp;&nbsp;&nbsp;&nbsp;this.timer(); &nbsp;&nbsp;}&nbsp;&nbsp;async&nbsp;timer()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(true)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(&#8216;hello&#8217;);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;await&nbsp;sleep(10000); &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;}&nbsp;&nbsp;async&nbsp;getUserInfo()&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(this.globalData.userInfo)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;this.globalData.userInfo; &nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;await&nbsp;wx.login();&nbsp;&nbsp;&nbsp;&nbsp;let&nbsp;res&nbsp;=&nbsp;await&nbsp;wx.getUserInfo();&nbsp;&nbsp;&nbsp;&nbsp;this.globalData.userInfo&nbsp;=&nbsp;res.userInfo;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;res.userInfo; [&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-28587","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28587","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=28587"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28587\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}