//子组件暴露整个类实例
import { Component } from "react";
import { View, Text, Image } from "@tarojs/components";
class Child extends Component {
constructor() {
super();
}
componentDidMount() {
this.props.refs(this)
}
say(){
console.log('1111');
}
render() {
return (
<View >
<Text>子组件</Text>
{this.props.children}
</View>
);
}
}
export default Child;
//父组件调用子组件方法
<Child refs={(c)=>this.child=c} />
this.child.say();
//1111