[英]How to control the button delete on react-admin list?
You can use npm i sweetalert2
like:您可以使用
npm i sweetalert2
喜欢:
import Swal from "sweetalert2";从“sweetalert2”导入 Swal; import axios from "axios";
从“axios”导入 axios;
onDeleteClick( pk) {
Swal.fire({
text :"Are you sure?,
title: "You won't be able to ,
type: "question",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: Yes!,
cancelButtonText: No!
}).then(result => {
if (result.value) {
axios
.delete(
`api ,
)
.then(res => {
Swal.fire({
title: "Deleted",
type: "success",
text: " Deleted Successfully !!",
showConfirmButton: false,
timer: 2000
});
})
.catch(err => {
console.log(err);
Swal.fire({
title: " Deleted",
type: "error",
text: "Error While deleting ??",
timer: 3000
});
});
}
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.