完美解决Vue项目在H5微信开发iOS真机上input和select调起软键盘后不回弹

直接上代码,简单粗暴

<input class="item-input" type="text" v-model="name" placeholder="请输入你的姓名" @blur="blurIn"/>
<select v-model="order.award_id" @blur="blurIn">
      <option v-for="item in awards" :value="item.id" :key="item.key">
        {{ item.title }}
      </option>
</select>

export default {
    computed: {
        scrollHeight () {
            return document.documentElement.scrollTop || document.body.scrollTop || 0
        }
    }
    methods: {
        blurIn () {
            window.scrollTo(0, Math.max(this.scrollHeight - 1, 0))
        }
    }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章