elementUI中MessageBox.confirm()默认不聚焦问题处理

在项目中使用elementUIMessageBox.confirm()出现了默认不聚焦的问题,默认确认按钮是浅色的,需要点击一下才会变成正常。面对这种问题,创建新组件,实现聚焦。替换默认的MessageBox.confirm()

  • 解决
  1. 创建components/MessageBoxConfirmWrapper/index.js
js 复制代码
import { MessageBox } from 'element-ui'

export default (...args) => {
	setTimeout(() => {
		document.activeElement?.blur()
	}, 0)
	return MessageBox.confirm(...args)
}
  1. 使用
js 复制代码
import MessageBoxConfirmWrapper from '@/components/MessageBoxConfirmWrapper'
MessageBoxConfirmWrapper('确定要退出当前账号?', '退出确认', { 
	type: 'warning'
 	})
	.then(() => {})
	.catch(() => {})
相关推荐
To_OC4 小时前
LC 131 分割回文串:刚学回溯时,我连怎么切字符串都想不明白
javascript·算法·leetcode
咩咩啃树皮5 小时前
第40篇:Vue3组件化开发精讲——组件拆分、复用、父子通信、工程化架构
java·前端·架构
阳光是sunny5 小时前
LangGraph中的Reducer是什么
前端·人工智能·后端
触底反弹5 小时前
一文搞懂 Tailwind CSS 弹性布局:从原理到实战
前端·css·html
阳光是sunny6 小时前
从链到图:LangGraph 入门基础全解析
前端·人工智能·后端
To_OC6 小时前
LC 42 接雨水:暴力超时卡半天?前后缀数组一用就通了
javascript·算法·leetcode
小林ixn6 小时前
从 ??= 到 onKeyDown:一个 React 组件的“自我修养”
前端·javascript·react.js
REDcker7 小时前
显示分辨率标准对照详解
前端·网络·分辨率·显示·屏幕
এ慕ོ冬℘゜7 小时前
前端实战:jQuery 多条件联合搜索(标题模糊查询 + 日历时间段筛选)
前端·javascript·jquery
武子康7 小时前
Search Console Platform Properties 扩大 SEO 资产边界:从 Page Ranking 到 Topic Coverage(5 类误读边界 + 3 表数据层设计)
前端·人工智能·后端