2
尝试将函数传递给子组件时,该函数未定义。其实我甚至不能直接在我的课堂上执行它。你认为有错字吗?在道具中传递函数未定义
class FriendsPage extends Component {
constructor(props){
super(props);
this.mylog = this.mylog.bind(this);
}
mylog(){
console.log("test debug");
}
renderItem(item) {
return (<User friend={item} key={item.id} mylog={this.mylog}/>);
}
class User extends Component {
constructor(props){
super(props);
}
render() {
this.props.mylog(); // <== This is undefined
...
}
@Jai没有,用户不延伸FriendsPage。 – Pankaj