Uniapp 隐藏软键盘的3种方法:input组件
可以使用以下方法隐藏Uniapp中的软键盘:
- 在input标签中添加属性'autofocus',并且在mounted钩子函数中使用this.$refs.input.blur()来隐藏软键盘。
<template>
<input type='text' ref='input' autofocus>
</template>
<script>
export default {
mounted() {
this.$refs.input.blur();
}
}
</script>
- 在input标签中添加属性'readonly',并且在mounted钩子函数中使用this.$refs.input.blur()来隐藏软键盘。
<template>
<input type='text' ref='input' readonly>
</template>
<script>
export default {
mounted() {
this.$refs.input.blur();
}
}
</script>
- 在input标签中添加属性'disabled',并且在mounted钩子函数中使用this.$refs.input.blur()来隐藏软键盘。
<template>
<input type='text' ref='input' disabled>
</template>
<script>
export default {
mounted() {
this.$refs.input.blur();
}
}
</script>
注意:以上方法只适用于Uniapp的input组件,对于其他组件可能需要采用不同的方法来隐藏软键盘。
原文地址: https://www.cveoy.top/t/topic/lKai 著作权归作者所有。请勿转载和采集!