完美解決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))
        }
    }
}

 

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