functionParentComponent(){consthandleClick=()=>{alert('Button clicked in parent!');};return<ChildComponentonClick={handleClick}/>;}functionChildComponent(props){returnClick Me;} In this case, the Parent passes a functionhandleClickto the Child, and the Child invokes it when the button is cl...
obj.attachEvent("on"+eventName,function(){//在ie低版本中,需要在事件名前加上on//在ie中事件绑定的处理函数this指向的window,需要用call将this指向obj,以便在事件处理函数中使用thisfn.call(obj); }); }else{ obj.addEventListener(eventName,fn,false); } } 使用封装函数: addEvent(obj,"click",clicnF...