首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何访问子组件中的父组件方法,如下所示

如何访问子组件中的父组件方法,如下所示
EN

Stack Overflow用户
提问于 2017-11-23 13:23:46
回答 0查看 44关注 0票数 0
代码语言:javascript
复制
//this is the parent component in ibios.js file

import  React from 'react';
import ReactDOM from 'react-dom';
import axios from 'axios';

class ibios extends React.Component{
  constructor(){
        super();
        this.sate={};
        this.get = this.get.bind(this);
    }
 get(ur,apiurl,prametars){
  prametars=prepareHeaderRequest;
    return axios.get(url+apiUrl,{params:prametars})
            .then(function(response){
                console.log(response.data);
            });
    }
    render(){
        return(
            <p>hi...</p>
            );
   }
}

//this is the child component chart component.js file

import React from 'react';
import ibios from '../ibios/IBIOS';
import ChartComponent from './chartcomponents';

class BarChartComponent extends ChartComponent{
  constructor(props){
        super(props)
        this.state={};  
    }
   componentDidMount(){
      //example
       var url="http://localhost:9090",apiUrl="/reports",prametrs={xyz:ramki};
     var retriveResponse=this.ibios.get(url,apiUrl,prametrs)
     console.log(retriveResponse);
   }
  render(){
     return(<p>hi......</p>);
  }
}

//我在ibos.get()?........................................................................................中只写过一次axios方法,以及如何继承每个组件以及如何通过axios直接获取响应............................................................................................................................................................................................................................

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47448124

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档