{"id":1318,"date":"2023-03-18T11:28:19","date_gmt":"2023-03-18T03:28:19","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1318"},"modified":"2023-04-29T09:12:48","modified_gmt":"2023-04-29T01:12:48","slug":"taro-basic-tutorial-react","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/taro-basic-tutorial-react\/","title":{"rendered":"Taro\u57fa\u7840\u6559\u7a0b\u4e4bReact"},"content":{"rendered":"<p>\u5728<code>Taro<\/code>\u53ef\u4ee5\u901a\u8fc7<code>import * as React from &#039;react&#039;<\/code>\u6765\u4f7f\u7528<code>React<\/code>\uff0c<code>JSX<\/code>\u8bed\u6cd5\u6ca1\u6709\u4efb\u4f55\u9650\u5236\uff0c\u4f46\u548c\u5728\u6d4f\u89c8\u5668\u4e2d\u4f7f\u7528<code>React<\/code>\u4f9d\u7136\u6709\u4e00\u4e9b\u4e0d\u540c\uff0c\u5177\u4f53\u4f53\u73b0\u5728\uff1a<\/p>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/taro-docs.jd.com\/taro\/docs\/react\/\">https:\/\/taro-docs.jd.com\/taro\/docs\/react\/<\/a><\/p>\n<h2>\u5165\u53e3\u7ec4\u4ef6<\/h2>\n<p><!-- more --><\/p>\n<p>\u6bcf\u4e00\u4e2a<code>Taro<\/code>\u5e94\u7528\u90fd\u9700\u8981\u4e00\u4e2a\u5165\u53e3\u7ec4\u4ef6\u7528\u6765\u6ce8\u518c\u5e94\u7528\uff0c\u5165\u53e3\u6587\u4ef6\u9ed8\u8ba4\u662f<code>src<\/code>\u76ee\u5f55\u4e0b\u7684<code>app.js<\/code>\uff0c\u5728<code>Taro<\/code>\u4e2d\u4f7f\u7528<code>React<\/code>\uff0c\u5165\u53e3\u7ec4\u4ef6\u5fc5\u987b\u5bfc\u51fa\u4e00\u4e2a<code>React<\/code>\u7ec4\u4ef6\uff0c\u5728\u5165\u53e3\u7ec4\u4ef6\u4e2d\u6211\u4eec\u53ef\u4ee5\u8bbe\u7f6e\u5168\u5c40\u72b6\u6001\u6216\u8bbf\u95ee\u5c0f\u7a0b\u5e8f\u5165\u53e3\u5b9e\u4f8b\u7684\u751f\u547d\u5468\u671f\uff1a<\/p>\n<pre><code class=\"language-javascript\">import React, { Component } from &#039;react&#039;\n\/\/ \u5047\u8bbe\u6211\u4eec\u8981\u4f7f\u7528 Redux\nimport { Provider } from &#039;react-redux&#039;\n\nimport configStore from &#039;.\/store&#039;\n\nimport &#039;.\/app.css&#039;\n\nconst store = configStore()\n\nclass App extends Component {\n  componentDidMount () {}\n\n  \/\/ \u5bf9\u5e94 onShow\n  componentDidShow () {}\n\n  \/\/ \u5bf9\u5e94 onHide\n  componentDidHide () {}\n\n  \/\/ \u5bf9\u5e94 onError\n  componentDidCatchError () {}\n\n  render () {\n    \/\/ \u5728\u5165\u53e3\u7ec4\u4ef6\u4e0d\u4f1a\u6e32\u67d3\u4efb\u4f55\u5185\u5bb9\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u5728\u8fd9\u91cc\u505a\u7c7b\u4f3c\u4e8e\u72b6\u6001\u7ba1\u7406\u7684\u4e8b\u60c5\n    return (\n      &lt;Provider store={store}&gt;\n        {this.props.children} \/* this.props.children \u662f\u5c06\u8981\u88ab\u6e32\u67d3\u7684\u9875\u9762 *\/\n      &lt;\/Provider&gt;\n    )\n  }\n}\n\nexport default App<\/code><\/pre>\n<p>\u5bf9\u4e8e\u4e00\u4e2a\u5165\u53e3\u6587\u4ef6(\u4f8b\u5982<code>app.jsx<\/code>)\u800c\u8a00\uff0c\u6211\u4eec\u53ef\u4ee5\u65b0\u589e\u4e00\u4e2a<code>app.config.js<\/code>\u7684\u6587\u4ef6\u8fdb\u884c\u5168\u5c40\u914d\u7f6e\uff0c<code>app.config.js<\/code>\u7684\u9ed8\u8ba4\u5bfc\u51fa\u5c31\u662f\u5168\u5c40\u914d\u7f6e\uff0c\u914d\u7f6e\u89c4\u8303\u57fa\u4e8e\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u7684\u5168\u5c40\u914d\u7f6e\u8fdb\u884c\u5236\u5b9a\uff0c\u6240\u6709\u5e73\u53f0\u8fdb\u884c\u7edf\u4e00:<\/p>\n<pre><code class=\"language-javascript\">\/\/ app.config.js\nexport default {\n  pages: [\n    &#039;pages\/index\/index&#039;\n  ],\n  window: {\n    backgroundTextStyle: &#039;light&#039;,\n    navigationBarBackgroundColor: &#039;#fff&#039;,\n    navigationBarTitleText: &#039;WeChat&#039;,\n    navigationBarTextStyle: &#039;black&#039;\n  }\n}<\/code><\/pre>\n<h3>\u7ec4\u4ef6\u751f\u547d\u5468\u671f<\/h3>\n<h4>onLaunch(options)<\/h4>\n<p>\u5728\u5fae\u4fe1\/\u767e\u5ea6\/\u5b57\u8282\u8df3\u52a8\/\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u4e2d\u8fd9\u4e00\u751f\u547d\u5468\u671f\u65b9\u6cd5\u5bf9\u5e94<code>app<\/code>\u7684<code>onLaunch<\/code><\/p>\n<p>\u5728\u6b64\u751f\u547d\u5468\u671f\u4e2d\u901a\u8fc7<code>getCurrentInstance().router.params<\/code>\uff0c\u53ef\u4ee5\u8bbf\u95ee\u5230\u7a0b\u5e8f\u521d\u59cb\u5316\u53c2\u6570\u3002<\/p>\n<h4>componentWillMount()<\/h4>\n<p>\u76d1\u542c\u7a0b\u5e8f\u521d\u59cb\u5316\uff0c\u521d\u59cb\u5316\u5b8c\u6210\u65f6\u89e6\u53d1\uff08\u5168\u5c40\u53ea\u89e6\u53d1\u4e00\u6b21\uff09<\/p>\n<h4>componentDidMount()<\/h4>\n<p>\u9875\u9762\u521d\u6b21\u6e32\u67d3\u5b8c\u6210\u65f6\u89e6\u53d1\uff0c\u4e00\u4e2a\u9875\u9762\u53ea\u4f1a\u8c03\u7528\u4e00\u6b21\uff0c\u4ee3\u8868\u9875\u9762\u5df2\u7ecf\u51c6\u5907\u59a5\u5f53\uff0c\u53ef\u4ee5\u548c\u89c6\u56fe\u5c42\u8fdb\u884c\u4ea4\u4e92\u3002\u6b64\u751f\u547d\u5468\u671f\u53ef\u4ee5\u8bbf\u95ee<code>getCurrentInstance().router<\/code>\u3002\u6b64\u751f\u547d\u5468\u671f\u53ef\u4ee5\u8bbf\u95ee<code>Taro DOM<\/code>\u5e76\u4e14\u66f4\u6539<code>DOM<\/code>\u6216\u6dfb\u52a0\u4e8b\u4ef6\uff0c\u4f46\u65e0\u6cd5\u901a\u8fc7<code>Taro.createSelectorQuery<\/code>\u67e5\u627e\u5c0f\u7a0b\u5e8f<code>DOM<\/code>\u3002<\/p>\n<h4>componentDidShow(options)<\/h4>\n<p>\u5728\u5fae\u4fe1\/\u767e\u5ea6\/\u5b57\u8282\u8df3\u52a8\/\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u4e2d\u8fd9\u4e00\u751f\u547d\u5468\u671f\u65b9\u6cd5\u5bf9\u5e94<code>onShow<\/code>\uff0c\u5728 H5\/RN \u4e2d\u540c\u6b65\u5b9e\u73b0<\/p>\n<p>\u7a0b\u5e8f\u542f\u52a8\uff0c\u6216\u4ece\u540e\u53f0\u8fdb\u5165\u524d\u53f0\u663e\u793a\u65f6\u89e6\u53d1\uff0c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u4e5f\u53ef\u4ee5\u4f7f\u7528<code>Taro.onAppShow<\/code>\u7ed1\u5b9a\u76d1\u542c<\/p>\n<p>\u5728\u6b64\u751f\u547d\u5468\u671f\u4e2d\u901a\u8fc7<code>getCurrentInstance().router.params<\/code>\uff0c\u53ef\u4ee5\u8bbf\u95ee\u5230\u7a0b\u5e8f\u521d\u59cb\u5316\u53c2\u6570<\/p>\n<p>\u53c2\u6570\u4e0e<code>componentWillMount<\/code>\u4e2d\u83b7\u53d6\u7684\u57fa\u672c\u4e00\u81f4\uff0c\u4f46\u767e\u5ea6\u5c0f\u7a0b\u5e8f\u4e2d\u8865\u5145<code>entryType<\/code>\u548c<code>appURL<\/code>\u4e24\u4e2a\u53c2\u6570<\/p>\n<h4>componentDidHide()<\/h4>\n<p>\u5728\u5fae\u4fe1\/\u767e\u5ea6\/\u5b57\u8282\u8df3\u52a8\/\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u4e2d\u8fd9\u4e00\u751f\u547d\u5468\u671f\u65b9\u6cd5\u5bf9\u5e94<code>onHide<\/code>\uff0c\u5728<code>H5\/RN<\/code>\u4e2d\u540c\u6b65\u5b9e\u73b0<\/p>\n<p>\u7a0b\u5e8f\u4ece\u524d\u53f0\u8fdb\u5165\u540e\u53f0\u65f6\u89e6\u53d1\uff0c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u4e5f\u53ef\u4ee5\u4f7f\u7528<code>Taro.onAppHide<\/code>\u7ed1\u5b9a\u76d1\u542c<\/p>\n<h4>componentDidCatchError(String error)<\/h4>\n<p>\u5728\u5fae\u4fe1\/\u767e\u5ea6\/\u5b57\u8282\u8df3\u52a8\/\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u4e2d\u8fd9\u4e00\u751f\u547d\u5468\u671f\u65b9\u6cd5\u5bf9\u5e94<code>onError<\/code>\uff0c<code>H5\/RN<\/code>\u4e2d\u5c1a\u672a\u5b9e\u73b0<\/p>\n<p>\u7a0b\u5e8f\u53d1\u751f\u811a\u672c\u9519\u8bef\u6216 API \u8c03\u7528\u62a5\u9519\u65f6\u89e6\u53d1\uff0c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u4e5f\u53ef\u4ee5\u4f7f\u7528<code>Taro.onError<\/code>\u7ed1\u5b9a\u76d1\u542c<\/p>\n<h4>componentDidNotFound(Object)<\/h4>\n<p>\u5728\u5fae\u4fe1\/\u5b57\u8282\u8df3\u52a8\u5c0f\u7a0b\u5e8f\u4e2d\u8fd9\u4e00\u751f\u547d\u5468\u671f\u65b9\u6cd5\u5bf9\u5e94<code>onPageNotFound<\/code>\uff0c\u5176\u4ed6\u7aef\u5c1a\u672a\u5b9e\u73b0<\/p>\n<p>\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u57fa\u7840\u5e93 1.9.90 \u5f00\u59cb\u652f\u6301<\/p>\n<p>\u7a0b\u5e8f\u8981\u6253\u5f00\u7684\u9875\u9762\u4e0d\u5b58\u5728\u65f6\u89e6\u53d1\uff0c\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\u4e5f\u53ef\u4ee5\u4f7f\u7528<code>Taro.onPageNotFound<\/code>\u7ed1\u5b9a\u76d1\u542c<\/p>\n<h2>\u9875\u9762\u7ec4\u4ef6<\/h2>\n<p>\u6bcf\u4e00\u4e2a<code>Taro<\/code>\u5e94\u7528\u90fd\u81f3\u5c11\u5305\u62ec\u4e00\u4e2a\u9875\u9762\u7ec4\u4ef6\uff0c\u9875\u9762\u7ec4\u4ef6\u53ef\u4ee5\u901a\u8fc7<code>Taro<\/code>\u8def\u7531\u8fdb\u884c\u8df3\u8f6c\uff0c\u4e5f\u53ef\u4ee5\u8bbf\u95ee\u5c0f\u7a0b\u5e8f\u9875\u9762\u7684\u751f\u547d\u5468\u671f\uff1a<\/p>\n<pre><code class=\"language-javascript\">import React, { Component } from &#039;react&#039;\nimport { View, Button, Text } from &#039;@tarojs\/components&#039;\n\nclass Index extends Component {\n\n  config = {\n    navigationBarTitleText: &#039;\u9996\u9875&#039;\n  }\n\n  \/\/ \u5bf9\u5e94 onShow\n  componentDidShow () { }\n\n  \/\/ \u5bf9\u5e94 onHide\n  componentDidHide () { }\n\n  \/\/ \u5bf9\u5e94 onPullDownRefresh\uff0c\u9664\u4e86 componentDidShow\/componentDidHide \u4e4b\u5916\uff0c\n  \/\/ \u6240\u6709\u9875\u9762\u751f\u547d\u5468\u671f\u51fd\u6570\u540d\u90fd\u4e0e\u5c0f\u7a0b\u5e8f\u76f8\u5bf9\u5e94\n  onPullDownRefresh () {\n  },\n\n  \/\/ \u5bf9\u5e94 onPullDownRefresh\n  onReachBottom () {\n  },\n\n  componentWillUnmount () { }\n\n  render () {\n    return (\n      &lt;View className=&#039;index&#039;&gt;\n      &lt;\/View&gt;\n    )\n  }\n}\n\nexport default Index<\/code><\/pre>\n<h3>\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>\u548c\u5165\u53e3\u7ec4\u4ef6\u4e00\u6837\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u9875\u9762\u6587\u4ef6(\u4f8b\u5982<code>.\/pages\/index\/index.jsx<\/code>)\u800c\u8a00\uff0c\u6211\u4eec\u53ef\u4ee5\u65b0\u589e\u4e00\u4e2a<code>.\/pages\/index\/index.config.js<\/code>\u7684\u6587\u4ef6\u8fdb\u884c\u9875\u9762\u914d\u7f6e\uff0c<code>index.config.js<\/code>\u7684\u9ed8\u8ba4\u5bfc\u51fa\u5c31\u662f\u9875\u9762\u914d\u7f6e\uff1a<\/p>\n<pre><code class=\"language-javascript\">\/\/ .\/pages\/index\/index.jsx\nexport default {\n  navigationBarTitleText: &#039;\u9996\u9875&#039;\n}<\/code><\/pre>\n<h3>\u751f\u547d\u5468\u671f<\/h3>\n<h4>onReady()<\/h4>\n<p>\u9875\u9762\u9996\u6b21\u6e32\u67d3\u5b8c\u6bd5\u65f6\u6267\u884c\uff0c\u6b64\u751f\u547d\u5468\u671f\u5728\u5c0f\u7a0b\u5e8f\u7aef\u5bf9\u5e94\u5c0f\u7a0b\u5e8f\u9875\u9762\u7684<code>onReady<\/code>\u751f\u547d\u5468\u671f\u3002\u4ece\u6b64\u751f\u547d\u5468\u671f\u5f00\u59cb\u53ef\u4ee5\u4f7f\u7528<code>createCanvasContext<\/code>\u6216<code>createselectorquery<\/code>\u7b49 API \u8bbf\u95ee\u771f\u5b9e DOM\u3002<\/p>\n<p>\u5728\u975e\u9875\u9762\u7ec4\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>Taro<\/code>\u5185\u7f6e\u7684 <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/taro-docs.jd.com\/taro\/docs\/react\/apis\/about\/events\" title=\"\u6d88\u606f\u673a\u5236\">\u6d88\u606f\u673a\u5236<\/a> \u8bbf\u95ee\u9875\u9762\u7ec4\u4ef6\u7684<code>onReady()<\/code>\u751f\u547d\u5468\u671f\uff1a<\/p>\n<pre><code class=\"language-javascript\">import { eventCenter, getCurrentInstance } from &#039;@tarojs\/taro&#039;\nclass Test extends React.Component {\n  componentDidMount () {\n    eventCenter.once(getCurrentInstance().router.onReady, () =&gt; {\n      const query = Taro.createSelectorQuery()\n      query.select(&#039;#only&#039;).boundingClientRect()\n      query.exec(res =&gt; {\n        console.log(res, &#039;res&#039;)\n      })\n      console.log(&#039;onReady&#039;)\n    })\n  }\n\n  render () {\n    return (\n      &lt;View id=&quot;only&quot;&gt;\n      &lt;\/View&gt;\n    )\n  }\n}<\/code><\/pre>\n<h4>onLoad(options)<\/h4>\n<p>\u9875\u9762\u521b\u5efa\u65f6\u6267\u884c\uff0c\u6b64\u751f\u547d\u5468\u671f\u5728\u5c0f\u7a0b\u5e8f\u7aef\u5bf9\u5e94\u5c0f\u7a0b\u5e8f\u9875\u9762\u7684<code>onLoad<\/code>\u751f\u547d\u5468\u671f\u3002\u6b64\u751f\u547d\u5468\u671f\u53ef\u4ee5\u8bbf\u95ee<code>getCurrentInstance().router<\/code>\u3002<\/p>\n<h4>componentWillMount()<\/h4>\n<p>\u9875\u9762\u52a0\u8f7d\u65f6\u89e6\u53d1\uff0c\u4e00\u4e2a\u9875\u9762\u53ea\u4f1a\u8c03\u7528\u4e00\u6b21\uff0c\u6b64\u65f6\u9875\u9762 DOM \u5c1a\u672a\u51c6\u5907\u597d\uff0c\u8fd8\u4e0d\u80fd\u548c\u89c6\u56fe\u5c42\u8fdb\u884c\u4ea4\u4e92<\/p>\n<h4>componentDidMount()<\/h4>\n<p>\u9875\u9762\u521d\u6b21\u6e32\u67d3\u5b8c\u6210\u65f6\u89e6\u53d1\uff0c\u4e00\u4e2a\u9875\u9762\u53ea\u4f1a\u8c03\u7528\u4e00\u6b21\uff0c\u4ee3\u8868\u9875\u9762\u5df2\u7ecf\u51c6\u5907\u59a5\u5f53\uff0c\u53ef\u4ee5\u548c\u89c6\u56fe\u5c42\u8fdb\u884c\u4ea4\u4e92\u3002\u6b64\u751f\u547d\u5468\u671f\u53ef\u4ee5\u8bbf\u95ee<code>getCurrentInstance().router<\/code>\u3002\u6b64\u751f\u547d\u5468\u671f\u53ef\u4ee5\u8bbf\u95ee Taro DOM \u5e76\u4e14\u66f4\u6539 DOM \u6216\u6dfb\u52a0\u4e8b\u4ef6\uff0c\u4f46\u65e0\u6cd5\u901a\u8fc7<code>Taro.createSelectorQuery<\/code>\u67e5\u627e\u5c0f\u7a0b\u5e8f DOM\u3002<\/p>\n<h4>shouldComponentUpdate(nextProps, nextState)<\/h4>\n<p>\u9875\u9762\u662f\u5426\u9700\u8981\u66f4\u65b0\uff0c\u8fd4\u56de<code>false<\/code>\u4e0d\u7ee7\u7eed\u66f4\u65b0\uff0c\u5426\u5219\u7ee7\u7eed\u8d70\u66f4\u65b0\u6d41\u7a0b<\/p>\n<h4>componentWillUpdate(nextProps, nextState)<\/h4>\n<p>\u9875\u9762\u5373\u5c06\u66f4\u65b0<\/p>\n<h4>componentDidUpdate(prevProps, prevState)<\/h4>\n<p>\u9875\u9762\u66f4\u65b0\u5b8c\u6bd5<\/p>\n<h4>componentWillUnmount()<\/h4>\n<p>\u9875\u9762\u5378\u8f7d\u65f6\u89e6\u53d1\uff0c\u5982<code>redirectTo<\/code>\u6216<code>navigateBack<\/code>\u5230\u5176\u4ed6\u9875\u9762\u65f6<\/p>\n<h4>componentDidShow()<\/h4>\n<p>\u9875\u9762\u663e\u793a\/\u5207\u5165\u524d\u53f0\u65f6\u89e6\u53d1<\/p>\n<h4>componentDidHide()<\/h4>\n<p>\u9875\u9762\u9690\u85cf\/\u5207\u5165\u540e\u53f0\u65f6\u89e6\u53d1\uff0c \u5982<code>navigateTo<\/code>\u6216\u5e95\u90e8<code>tab<\/code>\u5207\u6362\u5230\u5176\u4ed6\u9875\u9762\uff0c\u5c0f\u7a0b\u5e8f\u5207\u5165\u540e\u53f0\u7b49<\/p>\n<p>\u5728\u4ee5\u4e0a\u6240\u6709\u7684\u751f\u547d\u5468\u671f\u65b9\u6cd5\u4e2d\uff0c\u90fd\u53ef\u4ee5\u901a\u8fc7<code>getCurrentInstance().router.params<\/code>\u83b7\u53d6\u6253\u5f00\u5f53\u524d\u9875\u9762\u8def\u5f84\u4e2d\u7684\u53c2\u6570\u3002<\/p>\n<h3>\u9875\u9762\u4e8b\u4ef6\u5904\u7406\u51fd\u6570<\/h3>\n<p>\u5728\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u9875\u9762\u8fd8\u6709\u5728\u4e00\u4e9b\u4e13\u5c5e\u7684\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\uff0c\u5982\u4e0b<\/p>\n<h4>onPullDownRefresh()<\/h4>\n<p>\u76d1\u542c\u7528\u6237\u4e0b\u62c9\u5237\u65b0\u4e8b\u4ef6<\/p>\n<ul>\n<li>\u9700\u8981\u5728\u5168\u5c40\u914d\u7f6e\u7684<code>window<\/code>\u9009\u9879\u4e2d\u6216\u9875\u9762\u914d\u7f6e\u4e2d\u5f00\u542f<code>enablePullDownRefresh<\/code><\/li>\n<li>\u53ef\u4ee5\u901a\u8fc7<code>Taro.startPullDownRefresh<\/code>\u89e6\u53d1\u4e0b\u62c9\u5237\u65b0\uff0c\u8c03\u7528\u540e\u89e6\u53d1\u4e0b\u62c9\u5237\u65b0\u52a8\u753b\uff0c\u6548\u679c\u4e0e\u7528\u6237\u624b\u52a8\u4e0b\u62c9\u5237\u65b0\u4e00\u81f4<\/li>\n<li>\u5f53\u5904\u7406\u5b8c\u6570\u636e\u5237\u65b0\u540e\uff0c<code>Taro.stopPullDownRefresh<\/code>\u53ef\u4ee5\u505c\u6b62\u5f53\u524d\u9875\u9762\u7684\u4e0b\u62c9\u5237\u65b0<\/li>\n<\/ul>\n<h4>onReachBottom()<\/h4>\n<p>\u76d1\u542c\u7528\u6237\u4e0a\u62c9\u89e6\u5e95\u4e8b\u4ef6<\/p>\n<ul>\n<li>\u53ef\u4ee5\u5728\u5168\u5c40\u914d\u7f6e\u7684 window \u9009\u9879\u4e2d\u6216\u9875\u9762\u914d\u7f6e\u4e2d\u8bbe\u7f6e\u89e6\u53d1\u8ddd\u79bb onReachBottomDistance<\/li>\n<li>\u5728\u89e6\u53d1\u8ddd\u79bb\u5185\u6ed1\u52a8\u671f\u95f4\uff0c\u672c\u4e8b\u4ef6\u53ea\u4f1a\u88ab\u89e6\u53d1\u4e00\u6b21<\/li>\n<\/ul>\n<h4>onPageScroll(Object)<\/h4>\n<p>\u76d1\u542c\u7528\u6237\u6ed1\u52a8\u9875\u9762\u4e8b\u4ef6<\/p>\n<p>Object \u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u53c2\u6570<\/th>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>scrollTop<\/code><\/td>\n<td style=\"text-align: left;\">Number<\/td>\n<td style=\"text-align: left;\">\u9875\u9762\u5728\u5782\u76f4\u65b9\u5411\u5df2\u6eda\u52a8\u7684\u8ddd\u79bb\uff08\u5355\u4f4dpx\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>\u6ce8\u610f\uff1a\u8bf7\u53ea\u5728\u9700\u8981\u7684\u65f6\u5019\u624d\u5728<code>page<\/code>\u4e2d\u5b9a\u4e49\u6b64\u65b9\u6cd5\uff0c\u4e0d\u8981\u5b9a\u4e49\u7a7a\u65b9\u6cd5\u3002\u4ee5\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u4e8b\u4ef6\u6d3e\u53d1\u5bf9\u6e32\u67d3\u5c42-\u903b\u8f91\u5c42\u901a\u4fe1\u7684\u5f71\u54cd<br \/>\n\u6ce8\u610f\uff1a\u8bf7\u907f\u514d\u5728<code>onPageScroll<\/code>\u4e2d\u8fc7\u4e8e\u9891\u7e41\u7684\u6267\u884c<code>this.setState()<\/code>\u7b49\u5f15\u8d77\u903b\u8f91\u5c42-\u6e32\u67d3\u5c42\u901a\u4fe1\u7684\u64cd\u4f5c\u3002\u5c24\u5176\u662f\u6bcf\u6b21\u4f20\u8f93\u5927\u91cf\u6570\u636e\uff0c\u4f1a\u5f71\u54cd\u901a\u4fe1\u8017\u65f6<\/p>\n<\/blockquote>\n<h4>onShareAppMessage(Object)<\/h4>\n<p>\u76d1\u542c\u7528\u6237\u70b9\u51fb\u9875\u9762\u5185\u8f6c\u53d1\u6309\u94ae\uff08Button \u7ec4\u4ef6<code>openType=&#039;share&#039;<\/code>\uff09\u6216\u53f3\u4e0a\u89d2\u83dc\u5355\u201c\u8f6c\u53d1\u201d\u6309\u94ae\u7684\u884c\u4e3a\uff0c\u5e76\u81ea\u5b9a\u4e49\u8f6c\u53d1\u5185\u5bb9\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u53ea\u6709\u5b9a\u4e49\u4e86\u6b64\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\uff0c\u53f3\u4e0a\u89d2\u83dc\u5355\u624d\u4f1a\u663e\u793a\u201c\u8f6c\u53d1\u201d\u6309\u94ae<\/p>\n<p>Object \u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u53c2\u6570<\/th>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>from<\/code><\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">\u8f6c\u53d1\u4e8b\u4ef6\u6765\u6e90<br \/>button\uff1a\u9875\u9762\u5185\u8f6c\u53d1\u6309\u94ae<br \/>menu\uff1a\u53f3\u4e0a\u89d2\u8f6c\u53d1\u83dc\u5355<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>target<\/code><\/td>\n<td style=\"text-align: left;\">Object<\/td>\n<td style=\"text-align: left;\">\u5982\u679c<code>from<\/code>\u503c\u662f<code>button<\/code>\uff0c\u5219<code>target<\/code>\u662f\u89e6\u53d1\u8fd9\u6b21\u8f6c\u53d1\u4e8b\u4ef6\u7684<code>button<\/code>\uff0c<br \/>\u5426\u5219\u4e3a<code>undefined<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>webViewUrl<\/code><\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">\u9875\u9762\u4e2d\u5305\u542b<code>WebView<\/code>\u7ec4\u4ef6\u65f6\uff0c\u8fd4\u56de\u5f53\u524d WebView \u7684url<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6b64\u4e8b\u4ef6\u9700\u8981<code>return<\/code>\u4e00\u4e2a<code>Object<\/code>\uff0c\u7528\u4e8e\u81ea\u5b9a\u4e49\u8f6c\u53d1\u5185\u5bb9\uff0c\u8fd4\u56de\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<p>\u81ea\u5b9a\u4e49\u8f6c\u53d1\u5185\u5bb9<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u53c2\u6570<\/th>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>title<\/code><\/td>\n<td style=\"text-align: left;\">\u8f6c\u53d1\u6807\u9898<\/td>\n<td style=\"text-align: left;\">\u5f53\u524d\u5c0f\u7a0b\u5e8f\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>path<\/code><\/td>\n<td style=\"text-align: left;\">\u8f6c\u53d1\u8def\u5f84<\/td>\n<td style=\"text-align: left;\">\u5f53\u524d\u9875\u9762<code>path<\/code>\uff0c\u5fc5\u987b\u662f\u4ee5<code>\/<\/code>\u5f00\u5934\u7684\u5b8c\u6574\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>imageUrl<\/code><\/td>\n<td style=\"text-align: left;\">\u81ea\u5b9a\u4e49\u56fe\u7247\u8def\u5f84\uff0c\u53ef\u4ee5\u662f\u672c\u5730\u6587\u4ef6\u8def\u5f84\u3001\u4ee3\u7801\u5305\u6587\u4ef6\u8def\u5f84\u6216\u8005\u7f51\u7edc\u56fe\u7247\u8def\u5f84\u3002<br \/>\u652f\u6301 PNG \u53ca JPG \u3002\u663e\u793a\u56fe\u7247\u957f\u5bbd\u6bd4\u662f 5:4<\/td>\n<td style=\"text-align: left;\">\u4f7f\u7528\u9ed8\u8ba4\u622a\u56fe<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u793a\u4f8b\u4ee3\u7801<\/p>\n<pre><code class=\"language-javascript\">\/\/ page.js\nexport default class Index extends Component {\n  onShareAppMessage (res) {\n    if (res.from === &#039;button&#039;) {\n      \/\/ \u6765\u81ea\u9875\u9762\u5185\u8f6c\u53d1\u6309\u94ae\n      console.log(res.target)\n    }\n    return {\n      title: &#039;\u81ea\u5b9a\u4e49\u8f6c\u53d1\u6807\u9898&#039;,\n      path: &#039;\/page\/user?id=123&#039;\n    }\n  }\n}<\/code><\/pre>\n<h4>onResize(Object)<\/h4>\n<p>\u53ea\u6709\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u652f\u6301\uff0c\u57fa\u7840\u5e93 2.4.0 \u5f00\u59cb\u652f\u6301<\/p>\n<p>\u5c0f\u7a0b\u5e8f\u5c4f\u5e55\u65cb\u8f6c\u65f6\u89e6\u53d1\u3002\u8be6\u89c1 <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developers.weixin.qq.com\/miniprogram\/dev\/framework\/view\/resizable.html#%E5%9C%A8%E6%89%8B%E6%9C%BA%E4%B8%8A%E5%90%AF%E7%94%A8%E5%B1%8F%E5%B9%95%E6%97%8B%E8%BD%AC%E6%94%AF%E6%8C%81\" title=\"\u54cd\u5e94\u663e\u793a\u533a\u57df\u53d8\u5316\">\u54cd\u5e94\u663e\u793a\u533a\u57df\u53d8\u5316<\/a><\/p>\n<h4>onTabItemTap(Object)<\/h4>\n<p>\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u57fa\u7840\u5e93 1.9.0 \u5f00\u59cb\u652f\u6301<\/p>\n<p>\u70b9\u51fb<code>tab<\/code>\u65f6\u89e6\u53d1<\/p>\n<p><code>Object<\/code>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u53c2\u6570<\/th>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>index<\/code><\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">\u88ab\u70b9\u51fb tabItem \u7684\u5e8f\u53f7\uff0c\u4ece 0 \u5f00\u59cb<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>pagePath<\/code><\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">\u88ab\u70b9\u51fb tabItem \u7684\u9875\u9762\u8def\u5f84<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>text<\/code><\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">\u88ab\u70b9\u51fb tabItem \u7684\u6309\u94ae\u6587\u5b57<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>onAddToFavorites(Object)<\/h4>\n<p>Taro 3.0.3 \u7248\u672c\u5f00\u59cb\u652f\u6301\uff0c\u53ea\u6709\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u652f\u6301\uff0c\u672c\u63a5\u53e3\u4e3a Beta \u7248\u672c\uff0c\u5b89\u5353 7.0.15 \u7248\u672c\u8d77\u652f\u6301\uff0c\u6682\u53ea\u5728\u5b89\u5353\u5e73\u53f0\u652f\u6301<\/p>\n<p>\u76d1\u542c\u7528\u6237\u70b9\u51fb\u53f3\u4e0a\u89d2\u83dc\u5355\u201c\u6536\u85cf\u201d\u6309\u94ae\u7684\u884c\u4e3a\uff0c\u5e76\u81ea\u5b9a\u4e49\u6536\u85cf\u5185\u5bb9\u3002<\/p>\n<p><code>Object<\/code>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u53c2\u6570<\/th>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>webviewUrl<\/code><\/td>\n<td style=\"text-align: left;\">String<\/td>\n<td style=\"text-align: left;\">\u9875\u9762\u4e2d\u5305\u542bweb-view\u7ec4\u4ef6\u65f6\uff0c\u8fd4\u56de\u5f53\u524dweb-view\u7684url<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6b64\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u9700\u8981<code>return<\/code>\u4e00\u4e2a<code>Object<\/code>\uff0c\u7528\u4e8e\u81ea\u5b9a\u4e49\u6536\u85cf\u5185\u5bb9\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u53c2\u6570<\/th>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u9ed8\u8ba4\u503c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>title<\/code><\/td>\n<td style=\"text-align: left;\">\u81ea\u5b9a\u4e49\u6807\u9898<\/td>\n<td style=\"text-align: left;\">\u9875\u9762\u6807\u9898\u6216\u8d26\u53f7\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>imageUrl<\/code><\/td>\n<td style=\"text-align: left;\">\u81ea\u5b9a\u4e49\u56fe\u7247\uff0c\u663e\u793a\u56fe\u7247\u957f\u5bbd\u6bd4\u4e3a 1\uff1a1<\/td>\n<td style=\"text-align: left;\">\u9875\u9762\u622a\u56fe<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>query<\/code><\/td>\n<td style=\"text-align: left;\">\u81ea\u5b9a\u4e49query\u5b57\u6bb5<\/td>\n<td style=\"text-align: left;\">\u5f53\u524d\u9875\u9762\u7684query<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u793a\u4f8b\u4ee3\u7801<\/p>\n<pre><code class=\"language-javascript\">onAddToFavorites(res) {\n  \/\/ webview \u9875\u9762\u8fd4\u56de webviewUrl\n  console.log(&#039;WebviewUrl: &#039;, res.webviewUrl)\n  return {\n    title: &#039;\u81ea\u5b9a\u4e49\u6807\u9898&#039;,\n    imageUrl: &#039;http:\/\/demo.png&#039;,\n    query: &#039;name=xxx&amp;age=xxx&#039;,\n  }\n}<\/code><\/pre>\n<h4>onShareTimeline()<\/h4>\n<p>Taro 3.0.3 \u7248\u672c\u5f00\u59cb\u652f\u6301\uff0c\u53ea\u6709\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u652f\u6301\uff0c\u57fa\u7840\u5e93 2.11.3 \u5f00\u59cb\u652f\u6301\uff0c\u672c\u63a5\u53e3\u4e3a Beta \u7248\u672c\uff0c\u6682\u53ea\u5728 Android \u5e73\u53f0\u652f\u6301<\/p>\n<p>\u76d1\u542c\u53f3\u4e0a\u89d2\u83dc\u5355\u201c\u5206\u4eab\u5230\u670b\u53cb\u5708\u201d\u6309\u94ae\u7684\u884c\u4e3a\uff0c\u5e76\u81ea\u5b9a\u4e49\u5206\u4eab\u5185\u5bb9\u3002<\/p>\n<blockquote>\n<p>\u6ce8\u610f\uff1a\u53ea\u6709\u5b9a\u4e49\u4e86\u6b64\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\uff0c\u53f3\u4e0a\u89d2\u83dc\u5355\u624d\u4f1a\u663e\u793a\u201c\u5206\u4eab\u5230\u670b\u53cb\u5708\u201d\u6309\u94ae<\/p>\n<\/blockquote>\n<p>\u81ea\u5b9a\u4e49\u8f6c\u53d1\u5185\u5bb9<\/p>\n<p>\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a<code>Object<\/code>\uff0c\u7528\u4e8e\u81ea\u5b9a\u4e49\u5206\u4eab\u5185\u5bb9\uff0c\u4e0d\u652f\u6301\u81ea\u5b9a\u4e49\u9875\u9762\u8def\u5f84\uff0c\u8fd4\u56de\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u53c2\u6570<\/th>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u9ed8\u8ba4\u503c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">title<\/td>\n<td style=\"text-align: left;\">\u81ea\u5b9a\u4e49\u6807\u9898<\/td>\n<td style=\"text-align: left;\">\u5f53\u524d\u5c0f\u7a0b\u5e8f\u540d\u79f0<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">query<\/td>\n<td style=\"text-align: left;\">\u81ea\u5b9a\u4e49\u9875\u9762\u8def\u5f84\u4e2d\u643a\u5e26\u7684\u53c2\u6570<\/td>\n<td style=\"text-align: left;\">\u5f53\u524d\u9875\u9762\u8def\u5f84\u643a\u5e26\u7684\u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">imageUrl<\/td>\n<td style=\"text-align: left;\">\u81ea\u5b9a\u4e49\u56fe\u7247\u8def\u5f84\uff0c\u53ef\u4ee5\u662f\u672c\u5730\u6587\u4ef6\u6216\u8005\u7f51\u7edc\u56fe\u7247\u3002<br \/>\u652f\u6301 PNG \u53ca JPG\uff0c\u663e\u793a\u56fe\u7247\u957f\u5bbd\u6bd4\u662f 1:1<\/td>\n<td style=\"text-align: left;\">\u9ed8\u8ba4\u4f7f\u7528\u5c0f\u7a0b\u5e8f Logo<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre><code class=\"language-javascript\">\/\/ page.js\nclass Index extends Component {\n  onShareTimeline () {\n    console.log(&#039;onShareTimeline&#039;)\n  }\n}<\/code><\/pre>\n<h4>componentWillPreload()<\/h4>\n<p>\u76ee\u524d\u53ea\u6709\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u652f\u6301<\/p>\n<p><a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/taro-docs.jd.com\/taro\/docs\/best-practice#%E9%A2%84%E5%8A%A0%E8%BD%BD\" title=\"\u9884\u52a0\u8f7d\">\u9884\u52a0\u8f7d<\/a>\u94a9\u5b50<\/p>\n<h4>onTitleClick()<\/h4>\n<p>\u53ea\u6709\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u652f\u6301\uff0c\u57fa\u7840\u5e93 1.3.0 \u5f00\u59cb\u652f\u6301<\/p>\n<p>\u70b9\u51fb\u6807\u9898\u89e6\u53d1<\/p>\n<h4>onOptionMenuClick()<\/h4>\n<p>\u53ea\u6709\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u652f\u6301\uff0c\u57fa\u7840\u5e93 1.3.0 \u5f00\u59cb\u652f\u6301<\/p>\n<p>\u70b9\u51fb\u5bfc\u822a\u680f\u989d\u5916\u56fe\u6807\u89e6\u53d1<\/p>\n<h4>onPopMenuClick()<\/h4>\n<p>\u53ea\u6709\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u652f\u6301\uff0c\u57fa\u7840\u5e93 1.11.0 \u5f00\u59cb\u652f\u6301<\/p>\n<p>\u6682\u65e0\u8bf4\u660e<\/p>\n<h4>onPullIntercept()<\/h4>\n<p>\u53ea\u6709\u652f\u4ed8\u5b9d\u5c0f\u7a0b\u5e8f\u652f\u6301\uff0c\u57fa\u7840\u5e93 1.3.0 \u5f00\u59cb\u652f\u6301<\/p>\n<p>\u4e0b\u62c9\u622a\u65ad\u65f6\u89e6\u53d1<\/p>\n<p>H5 \u6682\u65f6\u6ca1\u6709\u540c\u6b65\u5b9e\u73b0<code>onReachBottom<\/code>\u3001<code>onPageScroll<\/code>\u8fd9\u4e24\u4e2a\u4e8b\u4ef6\u51fd\u6570\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ed9<code>window<\/code>\u7ed1\u5b9a<code>scroll<\/code>\u4e8b\u4ef6\u6765\u8fdb\u884c\u6a21\u62df\uff0c\u800c<code>onPullDownRefresh<\/code>\u4e0b\u62c9\u5237\u65b0\u5219\u6682\u65f6\u53ea\u80fd\u7528<code>ScrollView<\/code>\u7ec4\u4ef6\u6765\u4ee3\u66ff\u4e86\u3002<\/p>\n<blockquote>\n<p>\u6ce8\uff1a\u4ee5\u4e0a\u6210\u5458\u65b9\u6cd5\u5728 Taro \u7684\u9875\u9762\u4e2d\u540c\u6837\u53ef\u4ee5\u4f7f\u7528\uff0c\u4e66\u5199\u540c\u540d\u65b9\u6cd5\u5373\u53ef\uff0c\u4e0d\u8fc7\u9700\u8981\u6ce8\u610f\u7684\uff0c\u76ee\u524d\u6682\u65f6\u53ea\u6709\u5c0f\u7a0b\u5e8f\u7aef\u652f\u6301\uff08\u652f\u6301\u7a0b\u5ea6\u5982\u4e0a\uff09\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u7f16\u8bd1\u5230 H5\/RN \u7aef\u540e\u8fd9\u4e9b\u65b9\u6cd5\u5747\u4f1a\u5931\u6548\u3002<\/p>\n<\/blockquote>\n<h2>\u5185\u7f6e\u7ec4\u4ef6\/Props<\/h2>\n<p>Taro \u4e2d\u4f7f\u7528 React\uff0c\u5185\u7f6e\u7ec4\u4ef6\u9075\u5faa\u5c0f\u7a0b\u5e8f\u7ec4\u4ef6\u89c4\u8303\uff0c\u6240\u6709\u5185\u7f6e\u7ec4\u4ef6\u90fd\u5fc5\u987b\u4ece<code>@tarojs\/components<\/code>\u5f15\u5165\uff0c\u7ec4\u4ef6\u7684<code>Props<\/code>\u9075\u4ece\u5927\u9a7c\u5cf0\u5f0f\u547d\u540d\u89c4\u8303\uff1a<\/p>\n<h3>Taro<\/h3>\n<pre><code class=\"language-html\">import { View } from &#039;@tarojs\/components&#039;\n&lt;View hoverClass=&#039;test&#039; \/&gt;<\/code><\/pre>\n<p>\u5bf9\u5e94\u5c0f\u7a0b\u5e8f:<\/p>\n<pre><code class=\"language-html\">&lt;view hover-class=&#039;&#039; \/&gt;<\/code><\/pre>\n<h2>\u4e8b\u4ef6<\/h2>\n<p>\u5728 Taro \u4e2d\u4e8b\u4ef6\u9075\u4ece\u5c0f\u9a7c\u5cf0\u5f0f\u547d\u540d\u89c4\u8303\uff0c\u6240\u6709\u5185\u7f6e\u4e8b\u4ef6\u540d\u4ee5<code>on<\/code>\u5f00\u5934\uff0c\u5728\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\u4e2d\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u4e8b\u4ef6\u672c\u8eab\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528<code>stopPropagation<\/code>\u6765\u963b\u6b62\u5192\u6ce1\u3002<\/p>\n<pre><code class=\"language-javascript\">function Comp () {\n  \/\/ \u53ea\u6709 onClick \u5bf9\u5e94 bindtap\n  \/\/ \u5176\u4f59\u5185\u7f6e\u4e8b\u4ef6\u540d\n  function clickHandler (e) {\n    e.stopPropagation() \/\/ \u963b\u6b62\u5192\u6ce1\n  }\n\n  function scrollHandler () {\n    \/\/\n  }\n  return &lt;ScrollView onClick={clickHandler} onScroll={scrollHandler} \/&gt;\n}<\/code><\/pre>\n<h2>Hooks<\/h2>\n<p>Hooks \u6587\u6863\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/taro-docs.jd.com\/taro\/docs\/hooks\">https:\/\/taro-docs.jd.com\/taro\/docs\/hooks<\/a><\/p>\n<h2>\u5176\u5b83\u9650\u5236<\/h2>\n<p>\u7531\u4e8e\u5c0f\u7a0b\u5e8f\u4e0d\u652f\u6301\u52a8\u6001\u5f15\u5165\uff0c\u56e0\u6b64\u5c0f\u7a0b\u5e8f\u4e2d\u65e0\u6cd5\u4f7f\u7528 React.lazy API\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Taro\u53ef\u4ee5\u901a\u8fc7import * as React from &#039;react&#039;\u6765\u4f7f\u7528Rea [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34,36],"tags":[328],"class_list":["post-1318","post","type-post","status-publish","format-standard","hentry","category-node","category-react","tag-taro"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1318","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=1318"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1318\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}