Javascript 在初始荷载和稍后的某个单击事件上对荷载网格作出反应
在我的react应用程序中,我想调用一些AJAX调用来加载网格Javascript 在初始荷载和稍后的某个单击事件上对荷载网格作出反应,javascript,reactjs,Javascript,Reactjs,在我的react应用程序中,我想调用一些AJAX调用来加载网格 在初始屏幕加载期间 当某些事件发生时(假设按钮单击) 考虑到以上两种情况,下面的代码是否合适 async componentDidMount() { await this.loadGrids(); } loadGrids = async () => { // AJAX/Server Calls await this.loadColumns(); this.loadData(); } 我也
async componentDidMount() {
await this.loadGrids();
}
loadGrids = async () => {
// AJAX/Server Calls
await this.loadColumns();
this.loadData();
}
我也可以通过点击按钮手动调用“loadGrids”功能