微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Sweetalert 2 中的输入无法在材料 UI 模态反应 js 中键入

如何解决Sweetalert 2 中的输入无法在材料 UI 模态反应 js 中键入

我有一张卡片来显示订单,取消时卡片内会打开sweetalert2 弹出窗口,询问取消原因。这在订单屏幕上工作得很好。

enter image description here

<Grid item md={8} sm={12}>
    orders.map((order) => <supplierOrderBlock data={order} />)
</Grid>

并且在取消时这些swal 火。第一个要求用户输入原因,如果用户没有输入原因,第二个提示提示用户输入原因以取消。

const cancelOrder = (orderID,status) => {
    Swal.fire({
      title: "Are You Sure You Want to Cancel Order",text: "Please Enter the reason for the cancellation of order",input: "text",showCancelButton: true,confirmButtonColor: "#1c8fec",cancelButtonColor: "#fa013b",customClass: 'swal-wide'
    }).then((result) => {
      if (result.value == '') {
        swal({
          title: "You can not cancel without giving a reason",buttons: {
            Confirm: { text: "Okay",className: "okayButton" },},});
      }
else if (result.isConfirmed) { //cancel order}

这工作得很好。

现在,当我尝试在我的仪表板上的 Material UI 模式中使用相同的组件时,它不允许我输入文本。

<Modal
        open={modal}
        onClose={handleClose}
        aria-labelledby="simple-modal-title"
        aria-describedby="simple-modal-description"
        style={{ width: "60%",zIndex: 1,marginLeft: '-10%' }}
      >
        <Box style={{ marginLeft: "50%",marginTop: "25vh",width: "100%",position: 'absolute' }}>
          <supplierOrderBlock data={supplierorder} />
        </Box>
      </Modal>

enter image description here

如果我从 Modal 中删除 Z-index 属性,那么 swal 会落后于 modal

enter image description here

但是在关闭模态时,它让我们输入原因

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。