uni-app中uni-popup上input/textarea获取不到焦点解决方案

首先在popup上创建change事件


用上面创建的change事件控制focus状态值


将popup显示状态赋值给focus状态


将这两个方法覆盖原先uni-popup中的方法,代码如下粘贴

open() {

        this.showPopup = true

        this.$nextTick(() => {

          new Promise(resolve => {

            clearTimeout(this.timer)

            this.timer = setTimeout(() => {

              this.showTrans = true

              resolve();

            }, 50);

          }).then(res => {

            this.$emit('change', {

              show: true

            })

          })

        })

      },

      close(type) {

        this.showTrans = false

        this.$nextTick(() => {

          this.$emit('change', {

            show: false

          })

          clearTimeout(this.timer)

          this.timer = setTimeout(() => {

            this.showPopup = false

          }, 300)

        })

      },

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。