【Ant Design of Vue】Modal.confirm无法关闭的bug

一、问题

在使用 Ant Design Vue 的 Modal.confirm 确认框时,出现了点击取消和确定后 Modal.confirm 确认框无法关闭的问题

二、代码

代码完全是 copy 的官网的代码,但是 copy 到本地后就会出现上述问题

bash 复制代码
<template>
    <a-button @click="showConfirm">Confirm</a-button>
</template>
<script lang="ts">
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { createVNode, defineComponent } from 'vue';
import { Modal } from 'ant-design-vue';
export default defineComponent({
  setup() {
    const showConfirm = () => {
      Modal.confirm({
        title: 'Do you Want to delete these items?',
        icon: createVNode(ExclamationCircleOutlined),
        content: createVNode('div', { style: 'color:red;' }, 'Some descriptions'),
        onOk() {
          console.log('OK');
        },
        onCancel() {
          console.log('Cancel');
        },
        class: 'test',
      });
    };
    return {
      showConfirm,
    };
  },
});
</script>

三、解决方案

出现该问题的原因是因为:vue更新到 3.4.x 版本之后,某些 API 和 Ant Design Vue 不兼容

本人之前使用的版本是:

  • vue 3.4.7
  • ant-design-vue 3.2.20

解决方案:将vue版本修改并锁定为 3.2.20

相关推荐
spencer_tseng1 天前
Lombok.jar bug
bug·jar·lombok
一 乐1 天前
点餐|智能点餐系统|基于java+ Springboot的动端的点餐系统小程序(源码+数据库+文档)
java·前端·数据库·vue.js·spring boot·小程序·论文
视图猿人1 天前
RxJS基本使用及在next.js中使用的例子
开发语言·javascript
bitbitDown1 天前
从零打造一个 Vite 脚手架工具:比你想象的简单多了
前端·javascript·面试
冴羽1 天前
为什么在 JavaScript 中 NaN !== NaN?背后藏着 40 年的技术故事
前端·javascript·node.js
久爱@勿忘1 天前
vue下载项目内静态文件
前端·javascript·vue.js
前端炒粉1 天前
21.搜索二维矩阵 II
前端·javascript·算法·矩阵
不爱吃糖的程序媛1 天前
Electron 应用中的系统检测方案对比
前端·javascript·electron
pe7er1 天前
用高阶函数实现递归:从匿名函数到通用递归生成器
前端·javascript
Jonathan Star1 天前
NestJS 是基于 Node.js 的渐进式后端框架,核心特点包括 **依赖注入、模块化架构、装饰器驱动、TypeScript 优先、与主流工具集成** 等
开发语言·javascript·node.js