const { Button } = antd;
const { PoweroffOutlined } = icons;
class App extends React.Component {
state = {
loadings: [],
};
enterLoading = index => {
this.setState(({ loadings }) => {
const newLoadings = [...loadings];
newLoadings[index] = true;
return {
loadings: newLoadings,
};
});
setTimeout(() => {
this.setState(({ loadings }) => {
const newLoadings = [...loadings];
newLoadings[index] = false;
return {
loadings: newLoadings,
};
});
}, 6000);
};
render() {
const { loadings } = this.state;
return (
<>
}
loading={loadings[1]}
onClick={() => this.enterLoading(1)}
>
Click me!
}
loading={loadings[2]}
onClick={() => this.enterLoading(2)}
/>
>
);
}
}
ReactDOM.render(, mountNode);
https://ant.design/components/button-cn/#:~:text=Click me!-,加载中状态,-添加 loading 属性