//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直接获取响应............................................................................................................................................................................................................................
https://stackoverflow.com/questions/47448124
复制相似问题