Tom*_*asz 6 javascript ecmascript-6 reactjs
我想实现以下功能https://facebook.github.io/react/tips/expose-component-functions.html,但我使用的是ES6语法
@controllable(['center', 'zoom', 'hoverKey', 'clickKey', 'selectedCountry'])
export default class ContactMapView extends Component {
constructor(props) {
super(props);
this.initialFunc = this.initialFunc.bind(this);
}
initialFunc() { … }
Run Code Online (Sandbox Code Playgroud)
当我在父类中调用initialFunc时
componentDidMount() {
MapStore.addChangeListener(this._onChange.bind(this));
this.refs['mapView'].initialFunc();
};
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
TypeError: this.refs.mapView.initialFunc is not a function
Run Code Online (Sandbox Code Playgroud)
任何想法我怎么能运行我的子组件的功能?
| 归档时间: |
|
| 查看次数: |
570 次 |
| 最近记录: |