<template>
<view class="input">
<input type="text" :focus="isFocus" placeholder="测试" @focus="inputFocus()" @blur="inputBlur()" />
<button @click="btnClick">聚焦</button>
</view>
</template>
<script>
export default {
data() {
return {
isFocus: false,
}
},
onShow() {
},
onReady() {
this.focusChange();
},
methods: {
inputBlur(e){
this.isFocus = false;
console.log(this.isFocus);
},
inputFocus(e){
this.isFocus = true;
console.log(this.isFocus);
},
focusChange(){
this.isFocus = false;
this.$nextTick(()=>{
this.isFocus = true
console.log(this.isFocus);
})
},
btnClick(){
this.isFocus = !this.isFocus
console.log(this.isFocus);
},
}
}
</script>
<style lang="scss" scoped>
</style> - 发布:2026-10-16 16:45
- 更新:2026-10-16 16:45
- 阅读:29
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: windows11 25H2
HBuilderX类型: 正式
HBuilderX版本号: 4.87
手机系统: iOS
手机系统版本号: iOS 26
手机厂商: 苹果
手机机型: iphone 15pro
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
input组件设置focus属性为true,在小程序、安卓app中都可以实现自动聚焦,ios18系统也可以,ios27不会自动聚焦
input组件设置focus属性为true,在小程序、安卓app中都可以实现自动聚焦,ios18系统也可以,ios27不会自动聚焦
预期结果:
自动弹出软键盘
自动弹出软键盘
实际结果:
不弹出软键盘
不弹出软键盘
bug描述:
反馈bug处只能选择到ios26,没有ios27
input组件中设置focus属性为true在ios中不会自动聚焦
0 个回复