0
我有一個應用程序,它使用axios並使用我放在選項卡上的地圖呈現值(例如:ID和warehouseName)。現在我想要做的是通過我在地圖中獲得的值ID在warehouseID
的loadBrandTotal()
處發佈狀態。React -render值onClick選項卡
到目前爲止,我的代碼是這樣的
export default React.createClass({
getInitialState(){
return {
warehouseName: ""
}
},
componentWillMount(){
this.loadWarehouse();
this.loadBrandTotal();
},
loadWarehouse(){
var that = this
var url = api + 'retrieveWarehouseList';
axios.post(url,
{
warehouseName : 'NONE'
})
.then(function (response) {
console.log(response.data);
that.setState({
warehouseList : response.data.retrieveWarehouseListResult
});
})
.catch(function (response) {
console.log(response);
});
},
loadBrandTotal(){
var that = this
var url = api + 'retrieveTotalSalesPerBrand';
axios.post(url,
{
warehouseID : "None"
})
.then(function (response) {
console.log(response.data);
that.setState({
totsalesperbrand : response.data.retrieveTotalSalesPerBrandResult
});
})
.catch(function (response) {
console.log(response);
});
},
render() {
var wareName = this.state.warehouseList;
return (
\t <ul className="tabs tabs-transparent">
\t {wareName.map(function(nameoObjects) {
\t return (
\t <li className="tab">
\t <a href="#test1" value={nameoObjects.ID} key={nameoObjects.ID}>{nameoObjects.warehouseName}</a>
\t </li>
\t )
\t })}
\t </ul>
\t)}
})
非常感謝提前。