uni-ui icon indicating copy to clipboard operation
uni-ui copied to clipboard

uni-popup-dialog 组件 input 进入页面时自动弹出键盘

Open xluoyu opened this issue 3 years ago • 3 comments

使用ios真机测试时复现的问题

官方示例中也有此问题

xluoyu avatar Feb 17 '22 02:02 xluoyu

确实会这样 ,打开后会自动获取焦点

mehaotian avatar Feb 19 '22 03:02 mehaotian

我去年就遇到这个问题,后来为了避开它,自己写input,在 mounted 调用 setTimeout 设置 focus 为true。 现在vue3中,必须要使用uni-pop-dialog 才不报错,结果又遇到这个问题了。 苹果真机popup_focus问题

这是其他人遇到的一样的问题,[链接] uni-popup-dialog-input问题

rathubby avatar May 20 '22 02:05 rathubby

vue3 解决方案:

  1. 组件上加个v-if和ref
v-if="ifRenderDialog"
ref="inputDialog"
  1. 声明所需变量
const ifRenderDialog = ref<boolean>(false);
const vm = getCurrentInstance();
const inputDialog = ref<any>(null);
  1. 之后需要打开popup使用的时候再让他渲染到dom里如下
ifRenderDialog.value = true;
await nextTick();
// @ts-ignore
vm?.refs.inputDialog.open();

Ping-Gao avatar Aug 13 '22 17:08 Ping-Gao

感谢反馈,现已添加focus属性,请到插件市场更新,用户可自行控制打开弹窗时是否自动聚焦

18148764734 avatar Feb 02 '24 09:02 18148764734