https://www.daimajiaoliu.com/series/solution/46f998680100404
disabled
通过 Javascript 防止重复点击提交按钮,通常的做法是将按钮禁用通过 disabled 属性实现
jquery
$("form").submit(()=> {
$(":submit", this).attr("disabled","disabled");
});
react
function App() {
const [loading, setLoading] = useState(false);
async function onSubmit() {
setLoading(true);
const res = await $ajax();
if (res.code) {
setLoading(false);
}
}
return (
<Form>
<Button
disabled={loading}
type="primary"
onClick={onSubmit}
>提交</Button>
</Form>
);
}