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(() => {})
相关推荐
小呆呆6665 分钟前
Codex 穷鬼大救星
前端·人工智能·后端
当时只道寻常1 小时前
Vue3 + IntersectionObserver 实现高性能图片懒加载
前端
用户617517157011 小时前
关于普通函数和箭头函数的this
javascript
sakiko_1 小时前
UIKit学习笔记3-布局、滚动视图、隐藏或显示视图
前端·笔记·学习·objective-c·swift·uikit
RPGMZ1 小时前
RPGMakerMZ 地图存档点制作 标题继续游戏直接读取存档
开发语言·javascript·游戏·游戏引擎·rpgmz·rpgmakermz
有一个好名字2 小时前
Agent Loop —— 一切从那个 while 循环开始
前端·javascript·chrome
一天睡25小时2 小时前
Claude Code 指令入门教程
前端
EF@蛐蛐堂2 小时前
【js】浏览器滚动条优化组件OverlayScrollbars
开发语言·javascript·ecmascript
yingyima2 小时前
正则表达式实战:从日志中精准提取关键字段
前端
TeamDev2 小时前
如何在 DotNetBrowser 中使用本地 AI 模型
前端·后端·.net