📜  以参数为 prop 传递函数 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:34.848000             🧑  作者: Mango

代码示例1
class SomeComponent extends Component{

    constructor(props){
        super(props);
        //does whatever stuff        
        this.myFunction = this.myFunction.bind(this);

    }

    //(only applicable to raw and normal forms)
    myFunction(param){
        console.log('do something: ', param);
    }

    render(){
     return (
) } } class ChildComponent1{ render(){ return (
) } } class ChildComponent2{ render(){ return () } }