{"id":110842,"date":"2020-05-09T00:23:02","date_gmt":"2020-05-08T16:23:02","guid":{"rendered":"http:\/\/4563.org\/?p=110842"},"modified":"2020-05-09T00:23:02","modified_gmt":"2020-05-08T16:23:02","slug":"material-ui-react-%e7%bc%81%e5%8b%aa%e6%ac%a2%e9%8d%91%e8%8a%a5%e6%9a%9f%e9%96%b2%e5%b2%84%e6%bd%b0%e9%90%a8this-%e9%8f%88%ee%81%84%e7%95%be%e6%b6%94%e5%a4%8b%e6%a7%b8%e9%8e%ac%e5%ba%9d%e7%ae%9e","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=110842","title":{"rendered":"material ui React \u7f01\u52ea\u6b22\u9351\u82a5\u669f\u95b2\u5c84\u6f70\u9428?this \u93c8\ue044\u757e\u6d94\u590b\u69f8\u93ac\u5e9d\u7b9e\u9365\u70b0\u7c28\u951b?- V2EX"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  material ui React \u7f01\u52ea\u6b22\u9351\u82a5\u669f\u95b2\u5c84\u6f70\u9428?this \u93c8\ue044\u757e\u6d94\u590b\u69f8\u93ac\u5e9d\u7b9e\u9365\u70b0\u7c28\u951b?- V2EX<\/title> <link rel=\"dns-prefetch\" href=\"\/\/static.v2ex.com\" \/> <link rel=\"d               <\/h1>\n<p> <\/p>\n<div class=\">\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dyllen <\/span>  <span><i><\/i> 60<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>import React from 'react'; import AppBar from '@material-ui\/core\/AppBar'; import Toolbar from '@material-ui\/core\/Toolbar'; import Button from '@material-ui\/core\/Button'; import Typography from '@material-ui\/core\/Typography'; import DashboardIcon from '@material-ui\/icons\/Dashboard'; import IconButton from '@material-ui\/core\/IconButton'; import {Link} from 'react-router-dom'; import Menu from '@material-ui\/core\/Menu'; import MenuItem from '@material-ui\/core\/MenuItem';  class Header extends React.Component {     constructor(props) {         super(props);         this.state = {             anchorEl: null         };     }      handleClick(event)  {         console.log(event);         console.log(this);         this.setState({             anchorEl: event.currentTarget,         });     }      handleClose() {         console.log(342);         this.setState({             anchorEl: null,         });     }      render() {         return (             &lt;AppBar position=\"static\"&gt;                 &lt;Toolbar&gt;                     &lt;IconButton edge=\"start\" color=\"inherit\" aria-label=\"menu\"&gt;                         &lt;DashboardIcon \/&gt;                     &lt;\/IconButton&gt;                     &lt;Button color=\"inherit\"&gt;                         &lt;Link to=\"\/home\" className=\"menu-link\"&gt;                             \u68e3\u682d\u3009                         &lt;\/Link&gt;                     &lt;\/Button&gt;                     &lt;Button color=\"inherit\" onClick={this.handleClick}&gt;                         &lt;Link to=\"\/home\" className=\"menu-link\"&gt;                             \u9350\u546d\ue190\u7ee0\uff04\u608a                         &lt;\/Link&gt;                     &lt;\/Button&gt;                     &lt;Menu                         id=\"simple-menu\"                         anchorEl={this.anchorEl}                         keepMounted                         open={Boolean(this.anchorEl)}                         onClose={this.handleClose}                     &gt;                         &lt;MenuItem onClick={this.handleClose}&gt;Profile&lt;\/MenuItem&gt;                         &lt;MenuItem onClick={this.handleClose}&gt;My account&lt;\/MenuItem&gt;                         &lt;MenuItem onClick={this.handleClose}&gt;Logout&lt;\/MenuItem&gt;                     &lt;\/Menu&gt;                 &lt;\/Toolbar&gt;             &lt;\/AppBar&gt;         );     } }  export default Header; <\/code><\/pre>\n<p>\u6d60\uff47\u721c\u6fe1\u5099\u7b02,<code>Header<\/code>\u95b2\u5c84\u6f70\u9428?handleClick \u9351\u82a5\u669f\u951b\u5bbchis \u93bb\u612e\u305a<code>undefined<\/code>,\u93b4\u621c\u7ba3\u9353\u5d86\u5bdc\u9413\u0443\u757c\u93c2\u572d\u305a\u6e1a\u5b2a\ue11f\u9428\u52ec\u6902\u934a\u6b19\u7d1donClick \u7f01\u621d\u757e\u9428?code>class<\/code>\u9351\u82a5\u669f\u9428?code>this<\/code>\u93c4\ue21b\u6e41\u9428\u52f6\u7d1d\u9359\ue219\u4e92\u6d63\u8de8\u6564<code>this.setState<\/code>\u9428?\u93ac\u5e9d\u7b9e\u9352\u9881\u7c21\u6769\u6b13\u5677\u704f\u53d8\u7b09\u741b\u5c7c\u7c21\u935b\ue76e\u7d35<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"528789\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : shenyu1996 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/react.docschina.org\/docs\/handling-events.html \u7f01\u621d\u757e this \u93b4\u682c\u20ac\u546f\ue184\u6fb6\u6751\u56b1\u93c1?\/div> <\/td>\n<\/tr>\n<\/table><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"528790\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Justin13 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6d93\u5a44\ue184\u6fb6\u6751\u56b1\u93c1\u5e2e\u7d1d\u6769\u6b10\u69f8 js \u6d93\ue160\u6b91 this \u95c2\ue1c0\ue57d\u951b\u5c7d\u62f0 react \u5a0c\u2103\u6e41\u934f\u5d07\u90f4                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"528791\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : dyllen <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Justin13 @shenyu1996 \u942d\u30e9\u4ebe\u6d5c\u55ed\u7d1d\u93b0\u71bb\u963f\u9286?\/div> <\/td>\n<\/tr>\n<\/table><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"528792\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : newbieRenew <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9422?function \u935a\u044d\u7d1dhook\u951b\u5c80\ue184\u6fb6\u6751\u56b1\u93c1\u822c\u20ac\u509a\u76af\u6d5c\u55d7\u7de2\u6fb6?this \u9411\ufe3d\u4f21\u9286?\/div> <\/td>\n<\/tr>\n<\/table><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>material ui React&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\/110842"}],"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=110842"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/110842\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=110842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=110842"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=110842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}