Something beautiful is on the way.

elementui 的 iphone的el-select不能唤起输入

问题:

elementUI中有一个el-select组件。android、pc都正常的可以输入; 但是在iOS手机上,该组件无法唤起软键盘。

解决:

网上搜索一圈才知只兼容问题。大厂生产也不可避免bug。

input上有一个readonly 属性,而该属性只读。

方案1

<template>
    <el-select
        ref="select"
        @focus="clear"
        @hook:mounted="clear"
        @visible-change="clear"
    >
    </el-select>
</template>
<script>
    export default {
        methods: {
            clear(async) {
                this.$nextTick(() => {
			        if (!async) {
			          // ios 手机有延迟问题
			          setTimeout(() => {
			            const { select } = this.$refs
			            const input = select.$el.querySelector('.el-input__inner')
			            input.removeAttribute('readonly')
			          }, 200)
			        }
			     })
            }
        }
    }
</script>```
posted @ 2025-05-26 14:04  张朋举  阅读(147)  评论(0)    收藏  举报