<template>
<view>
<input type="search" placeholder="搜索商品" placeholder-style="color:#adaeba;" :focus="firstFocus" @change='firstChange'/>
</view>
</template>
<script>
export default {
data() {
return {
firstFocus:false
}
},
onShow() {
//调用fisrtChange
this.firstChange()
},
methods: {
firstChange() {
this.firstFocus = false; // 每次都要初始化 focus 属性
setTimeout(() => {
this.firstFocus = true; //自动获取焦点
},0)
}
}
}
</script>
input自动获取焦点弹出键盘
最新推荐文章于 2022-09-28 16:17:27 发布