{"id":271979,"date":"2021-01-11T19:24:18","date_gmt":"2021-01-11T11:24:18","guid":{"rendered":"http:\/\/4563.org\/?p=271979"},"modified":"2021-01-11T19:24:18","modified_gmt":"2021-01-11T11:24:18","slug":"%e6%b1%82-react-%e5%a4%a7%e4%bd%ac-%e5%a6%82%e4%bd%95%e5%9c%a8%e6%b5%8f%e8%a7%88%e5%99%a8%e6%8e%a7%e5%88%b6%e5%8f%b0%e9%80%9a%e8%bf%87-js-%e6%88%96-jq-%e8%a7%a6%e5%8f%91-react-%e7%9a%84%e6%95%b0","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=271979","title":{"rendered":"[\u6c42 React \u5927\u4f6c] \u5982\u4f55\u5728\u6d4f\u89c8\u5668\u63a7\u5236\u53f0\u901a\u8fc7 JS \u6216 JQ \u89e6\u53d1 React \u7684\u6570\u636e\u4fee\u6539\u4e8b\u4ef6\uff0c\u5e76\u4fee\u6539\u53d8\u91cf\u5185\u5bb9"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  [\u6c42 React \u5927\u4f6c] \u5982\u4f55\u5728\u6d4f\u89c8\u5668\u63a7\u5236\u53f0\u901a\u8fc7 JS \u6216 JQ \u89e6\u53d1 React \u7684\u6570\u636e\u4fee\u6539\u4e8b\u4ef6\uff0c\u5e76\u4fee\u6539\u53d8\u91cf\u5185\u5bb9               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zty7723271 <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u8865\u5145\u4fe1\u606f\uff1a<\/p>\n<ol>\n<li>\u9875\u9762\u81ea\u7136\u6e32\u67d3\u5b8c\u6210\u540e\uff0cDOM \u4e8b\u4ef6\u53ea\u6709 ReactEventListener.js \u91cc\u7684\u4e8b\u4ef6\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u5728\u63a7\u5236\u53f0\u6ca1\u6709\u529e\u6cd5\u76f4\u63a5\u8c03\u7528\u89e6\u53d1<\/li>\n<li>DOM \u662f\u901a\u8fc7 jsonp \u7684\u65b9\u5f0f\u6e32\u67d3\u7684\u865a\u62df dom\uff0c\u5404\u76d1\u542c\u4e8b\u4ef6\u5c31\u662f\u5728 jsonp \u8fd4\u56de\u7684 js \u65b9\u6cd5\u91cc\u9762\u4e0e ReactEventListener.js \u91cc\u7684\u4e8b\u4ef6\u8fdb\u884c\u7ed1\u5b9a\u7684<\/li>\n<li>\u60f3\u8981\u5728\u63a7\u5236\u53f0\u8f93\u5165\u524d\u7aef\u811a\u672c\u505a\u7684\u4e8b\u60c5\u662f\uff1a&#8221;\u4fee\u6539\u8868\u5355\u6807\u7b7e\u5185\u5bb9&#8221; -&gt; &#8220;\u89e6\u53d1\u7f51\u7ad9\u539f\u6709 dom \u7684 onchange \u4e8b\u4ef6&#8221; -&gt; &#8220;\u63d0\u4ea4\u8868\u5355\u83b7\u53d6\u7ed3\u679c&#8221;\u3002\uff08\u518d\u5177\u4f53\u70b9\u5c31\u662f\uff1a\u4fee\u6539 input \u7684\u503c -&gt; \u89e6\u53d1 input \u7684 onchange \u4e8b\u4ef6 -&gt; \u70b9\u51fb\u641c\u7d22\u6309\u94ae\u83b7\u53d6\u7ed3\u679c\uff09<\/li>\n<li>\u963b\u585e\u73b0\u8c61\u63cf\u8ff0\uff1a\u53ef\u4ee5\u4fee\u6539 input \u6807\u7b7e\u7684\u5185\u5bb9\uff0c\u4f46\u4ec5\u4ec5\u4fee\u6539\u53ea\u662f\u5728\u7559\u5728\u663e\u793a\u5c42\u9762\uff0c\u63d0\u4ea4\u8868\u5355\u540e\uff0c\u8fd8\u662f\u4f1a\u4f7f\u7528 input \u6807\u7b7e\u4fee\u6539\u524d\u7684\u503c\u53bb\u83b7\u53d6\u7ed3\u679c<\/li>\n<\/ol><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4899103\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : IGJacklove <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5728 react \u91cc\u9762\u628a\u4e8b\u4ef6\u7ed1\u5b9a\u5230 window \u4e0a\uff1f\u8fd9\u6837\u53ef\u4ee5\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4899104\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : weixiangzhe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e4b\u524d\u6211\u64b8\u4e86\u4e2a\u6cb9\u7334\u7684\u65f6\u5019\u6709\u627e\u8fc7\uff0cvue,react \u4e8b\u4ef6\u90fd\u7ed1\u5b9a\u5230 dom \u4e0a\u4e86\uff0c\u9700\u8981\u81ea\u5df2\u89e6\u53d1\u4e00\u4e2a\u4e8b\u4ef6<\/p>\n<p>&#8220;`js<br \/>const mouseClickEvents = [&#8216;mousedown&#8217;, &#8216;click&#8217;, &#8216;mouseup&#8217;];<br \/>function simulateMouseClick(element){<br \/> mouseClickEvents.forEach(mouseEventType =&gt;<br \/> element.dispatchEvent(<br \/> new MouseEvent(mouseEventType, {<br \/> view: window,<br \/> bubbles: true,<br \/> cancelable: true,<br \/> buttons: 1<br \/> })<br \/> )<br \/> );<br \/>}<\/p>\n<p>var element = document.querySelector(&#8216;div[class=&#8221;UFIInputContainer&#8221;]&#8217;);<br \/>simulateMouseClick(element);<br \/>&#8220;`<\/p>\n<p>\u6765\u81ea https:\/\/stackoverflow.com\/questions\/40091000\/simulate-click-event-on-react-element                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4899105\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : justin2018 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5b66\u4e60\u4e86 ~~~                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4899106\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xiaojiqiaozhi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u83b7\u53d6 input \u7684 ref\uff0c\u7ed9 ref \u52a0\u4e2a onchange \u76d1\u542c\u4e8b\u4ef6                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4899107\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gouflv <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5168\u5c40 event-bus                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4899108\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zty7723271 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @weixiangzhe \u611f\u8c22\uff01\uff01\uff01\u4eb2\u6d4b\u53ef\u884c\uff0c\u4e0b\u5468\u4e0d\u7528\u82b1 2 \u5929\u65f6\u95f4\u91cd\u65b0\u505a\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4899109\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yazoox <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u725b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4899110\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : px920906 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             react developer tools \u4e86\u89e3\u4e00\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>[\u6c42 React \u5927\u4f6c] \u5982\u4f55\u5728\u6d4f&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/271979"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=271979"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/271979\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=271979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=271979"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=271979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}